Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
How to detect a double's significant digits
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 29 - Collapse all  -  Translate all to Translated (View all originals)   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
mrstephengross  
View profile  
 More options May 5 2005, 1:37 pm
Newsgroups: comp.lang.python
From: "mrstephengross" <mrstephengr...@hotmail.com>
Date: 5 May 2005 10:37:00 -0700
Subject: How to detect a double's significant digits
Hi all... How can I find out the number of significant digits (to the
right of the decimal place, that is) in a double? At least, I *think*
that's what I'm asking for. For instance:

0.103 --> 3
0.0103 --> 4
0.00103 --> 5
0.000103 --> 6
0.0000103 --> 7

Thanks in advance!
--Steve (mrstephengr...@hotmail.com)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Stroud  
View profile  
 More options May 5 2005, 1:51 pm
Newsgroups: comp.lang.python
From: James Stroud <jstr...@mbi.ucla.edu>
Date: Thu, 5 May 2005 10:51:29 -0700
Local: Thurs, May 5 2005 1:51 pm
Subject: Re: How to detect a double's significant digits
Significant digits are an accounting concept. As such, it is up to the
accountant to keep track of these as only she knows the precision of her
measurements.

Koan for the day:

What are the significant digits of 0.1?

Hint:

>>> `0.1`

James

On Thursday 05 May 2005 10:37 am, so sayeth mrstephengross:

> Hi all... How can I find out the number of significant digits (to the
> right of the decimal place, that is) in a double? At least, I *think*
> that's what I'm asking for. For instance:

> 0.103 --> 3
> 0.0103 --> 4
> 0.00103 --> 5
> 0.000103 --> 6
> 0.0000103 --> 7

> Thanks in advance!
> --Steve (mrstephengr...@hotmail.com)

--
James Stroud, Ph.D.
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mrstephengross  
View profile  
 More options May 5 2005, 1:57 pm
Newsgroups: comp.lang.python
From: "mrstephengross" <mrstephengr...@hotmail.com>
Date: 5 May 2005 10:57:43 -0700
Local: Thurs, May 5 2005 1:57 pm
Subject: Re: How to detect a double's significant digits
So how can I get the kind of information I want then?

For example:

0.103 --> 3
0.0103 --> 4
0.00103 --> 5
0.000103 --> 6
0.0000103 --> 7

Any ideas?
--Steve


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
phil  
View profile  
 More options May 5 2005, 2:04 pm
Newsgroups: comp.lang.python
From: phil <phillip.wa...@anvilcom.com>
Date: Thu, 05 May 2005 13:04:21 -0500
Local: Thurs, May 5 2005 2:04 pm
Subject: Re: How to detect a double's significant digits
fl = 1.0002
x = str(fl)
pos = x.find('.')
print len( x[pos+1:] )
 >>> 4


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mrstephengross  
View profile  
 More options May 5 2005, 2:13 pm
Newsgroups: comp.lang.python
From: "mrstephengross" <mrstephengr...@hotmail.com>
Date: 5 May 2005 11:13:46 -0700
Local: Thurs, May 5 2005 2:13 pm
Subject: Re: How to detect a double's significant digits
Ok, that won't work. First of all, str() is not a function. If I want
to convert the float into a string, the conversion function will have
to use some kind of numeric precision, which will screw things up.
Consider this:

float f = 1.004;
ostringstream s;
s << f;
cout << s.str();

The above code may produce "1.004", or "1.0040", or "1.00400",
depending on the stream's precision setting. I need a way to detect the
number of digits to the right of decimal point *prior* to doing any
kind of string conversion.

--Steve


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steven Bethard  
View profile  
 More options May 5 2005, 2:15 pm
Newsgroups: comp.lang.python
From: Steven Bethard <steven.beth...@gmail.com>
Date: Thu, 05 May 2005 12:15:07 -0600
Local: Thurs, May 5 2005 2:15 pm
Subject: Re: How to detect a double's significant digits

mrstephengross wrote:
> So how can I get the kind of information I want then?

> For example:

> 0.103 --> 3
> 0.0103 --> 4
> 0.00103 --> 5
> 0.000103 --> 6
> 0.0000103 --> 7

Beware that this is probably only relevant if you have your numbers as
strings, not as floats:

py> 0.103
0.10299999999999999

But, assuming you have your numbers as strings, I would suggest looking
at str.split() and len().  I'd give you an example, but this sounds
kinda like a homework assignment.

STeVe


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steven Bethard  
View profile  
 More options May 5 2005, 2:17 pm
Newsgroups: comp.lang.python
From: Steven Bethard <steven.beth...@gmail.com>
Date: Thu, 05 May 2005 12:17:15 -0600
Local: Thurs, May 5 2005 2:17 pm
Subject: Re: How to detect a double's significant digits

mrstephengross wrote:
> First of all, str() is not a function.

Yes it is.

> float f = 1.004;
> ostringstream s;
> s << f;
> cout << s.str();

This doesn't look like Python to me.  Are you sure you're on the right
newsgroup?

STeVe


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mrstephengross  
View profile  
 More options May 5 2005, 2:20 pm
Newsgroups: comp.lang.python
From: "mrstephengross" <mrstephengr...@hotmail.com>
Date: 5 May 2005 11:20:22 -0700
Local: Thurs, May 5 2005 2:20 pm
Subject: Re: How to detect a double's significant digits
>But, assuming you have your numbers as strings, I would suggest

looking
at str.split() and len().

Well, the numbers are in fact stored as numbers, so string processing
won't work.

>I'd give you an example, but this sounds kinda like a homework

assignment.

The task may sound like it comes from class, but I can assure you that
I am indeed a professional developer. I'm doing some rather intricate
text processing / rendering stuff these days, and C++ is unfortunately
none too handy for that sort of thing. Unfortunately, I have to use it
for the task.

Thanks,
--Steve


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steven Bethard  
View profile  
 More options May 5 2005, 2:24 pm
Newsgroups: comp.lang.python
From: Steven Bethard <steven.beth...@gmail.com>
Date: Thu, 05 May 2005 12:24:23 -0600
Local: Thurs, May 5 2005 2:24 pm
Subject: Re: How to detect a double's significant digits

mrstephengross wrote:
> Well, the numbers are in fact stored as numbers, so string processing
> won't work.

What kind of numbers?  Python floats?

STeVe


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steven Bethard  
View profile  
 More options May 5 2005, 2:30 pm
Newsgroups: comp.lang.python
From: Steven Bethard <steven.beth...@gmail.com>
Date: Thu, 05 May 2005 12:30:53 -0600
Local: Thurs, May 5 2005 2:30 pm
Subject: Re: How to detect a double's significant digits

mrstephengross wrote:
>>But, assuming you have your numbers as strings, I would suggest

> looking
> at str.split() and len().

> Well, the numbers are in fact stored as numbers, so string processing
> won't work.

How about:

py> def digits(f):
...     return len(str(f).split('.')[1].rstrip('0'))
...
py> for f in [0.103, 0.1030, 0.0103, 0.010300]:
...     print f, digits(f)
...
0.103 3
0.103 3
0.0103 4
0.0103 4

I believe the rstrip is unnecessary because I think str() will never
produce additional following zeros, but you can guarantee it by calling
rstrip if you want.

Note that, for example, 0.103 and 0.1030 are identical as far as Python
is concerned, so I hope you're not hoping to show a difference between
these two...

STeVe


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Charles Krug  
View profile  
 More options May 5 2005, 2:42 pm
Newsgroups: comp.lang.python
From: Charles Krug <cdk...@worldnet.att.net>
Date: Thu, 05 May 2005 18:42:17 GMT
Local: Thurs, May 5 2005 2:42 pm
Subject: Re: How to detect a double's significant digits
On 5 May 2005 10:37:00 -0700, mrstephengross <mrstephengr...@hotmail.com> wrote:

> Hi all... How can I find out the number of significant digits (to the
> right of the decimal place, that is) in a double? At least, I *think*
> that's what I'm asking for. For instance:

> 0.103 --> 3
> 0.0103 --> 4
> 0.00103 --> 5
> 0.000103 --> 6
> 0.0000103 --> 7

> Thanks in advance!
> --Steve (mrstephengr...@hotmail.com)

I would say that each of these examples has three signficant figures.
Each of them can be expressed as:

1.03e+n

For any integer n.

The fact that you've only shown the cases where n \in {-1, -2, -3, -4,
-5 . . } doesn't change the generality of the answer.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Grant Edwards  
View profile  
 More options May 5 2005, 2:43 pm
Newsgroups: comp.lang.python
From: Grant Edwards <gra...@visi.com>
Date: Thu, 05 May 2005 18:43:51 -0000
Local: Thurs, May 5 2005 2:43 pm
Subject: Re: How to detect a double's significant digits
On 2005-05-05, mrstephengross <mrstephengr...@hotmail.com> wrote:

>>But, assuming you have your numbers as strings, I would suggest
> looking
> at str.split() and len().

> Well, the numbers are in fact stored as numbers,

Then your question is in fact meaningless.  The related
question that can be answered is "where is the least
significant '1' bit in the IEEE representation".  If that's
useful information, the struct module will help you find it.

> so string processing won't work.

That's the only way to answer the question you asked.

>>I'd give you an example, but this sounds kinda like a homework
>> assignment.

> The task may sound like it comes from class, but I can assure
> you that I am indeed a professional developer. I'm doing some
> rather intricate text processing / rendering stuff these days,
> and C++ is unfortunately none too handy for that sort of
> thing. Unfortunately, I have to use it for the task.

--
Grant Edwards                   grante             Yow!  Hmmm... A hash-singer
                                  at               and a cross-eyed guy were
                               visi.com            SLEEPING on a deserted
                                                   island, when...

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mrstephengross  
View profile  
 More options May 5 2005, 3:14 pm
Newsgroups: comp.lang.python
From: "mrstephengross" <mrstephengr...@hotmail.com>
Date: 5 May 2005 12:14:41 -0700
Local: Thurs, May 5 2005 3:14 pm
Subject: Re: How to detect a double's significant digits
>This doesn't look like Python to me.  Are you sure you're on the right

newsgroup?

Er, ok, I'm an idiot. This was all supposed to be on comp.lang.c++, but
obviously I posted on the wrong one. Sorry for all the hassle. In
python, this stuff is a heck of a lot easier.

--Steve


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
phil  
View profile  
 More options May 5 2005, 3:16 pm
Newsgroups: comp.lang.python
From: phil <phillip.wa...@anvilcom.com>
Date: Thu, 05 May 2005 14:16:34 -0500
Local: Thurs, May 5 2005 3:16 pm
Subject: Re: How to detect a double's significant digits
Bollocks, works here.

That looks like Java!!!  Aaaihh!


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Otten  
View profile  
 More options May 5 2005, 3:29 pm
Newsgroups: comp.lang.python
From: Peter Otten <__pete...@web.de>
Date: Thu, 05 May 2005 21:29:36 +0200
Local: Thurs, May 5 2005 3:29 pm
Subject: Re: How to detect a double's significant digits

mrstephengross wrote:
> This was all supposed to be on comp.lang.c++, but

You may still want to read the following thread on Python-Dev:
http://mail.python.org/pipermail/python-dev/2004-March/043703.html

A link mentioned by Andrew Koenig may be helpful:
http://www.netlib.org/fp/

"""
file    g_fmt.c
by      David Gay
for     ANSI C or C++ source for function g_fmt(char *, double):
,       with help from dtoa, g_fmt(buf, x) sets buf to the shortest
,       decimal string that correctly rounds to x and returns buf.
"""

Peter


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Fredrik Lundh  
View profile  
 More options May 5 2005, 3:30 pm
Newsgroups: comp.lang.python
From: "Fredrik Lundh" <fred...@pythonware.com>
Date: Thu, 5 May 2005 21:30:13 +0200
Local: Thurs, May 5 2005 3:30 pm
Subject: Re: How to detect a double's significant digits

"mrstephengross" wrote:
> >But, assuming you have your numbers as strings, I would suggest
> looking
> at str.split() and len().

> Well, the numbers are in fact stored as numbers, so string processing
> won't work.

if they're not strings, your question is meaningless.  as others have
pointed out, the exact internal representation for 0.103 is more like
0.10299999999999999433786257441170164383947849273681640625
which has a lot more than 3 digits...

> >I'd give you an example, but this sounds kinda like a homework
> assignment.

> The task may sound like it comes from class, but I can assure you that
> I am indeed a professional developer.

well professional or not, you clearly need to refresh your floating point
skills.  I suggest reading the following documents before proceeding:

    http://docs.python.org/tut/node16.html
    http://www.lahey.com/float.htm

</F>


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeremy Bowers  
View profile  
 More options May 5 2005, 4:32 pm
Newsgroups: comp.lang.python
From: Jeremy Bowers <j...@jerf.org>
Date: Thu, 05 May 2005 16:32:38 -0400
Local: Thurs, May 5 2005 4:32 pm
Subject: Re: How to detect a double's significant digits

You beat me to it.

Step one for mrstephengross is to *rigorously* define what he means by
"significant digits", then go from there. Since I think he mentioned
something about predicting how much space it will take to print out, my
suggestion is to run through whatever printing routines there are and get
a string out, the measure the string, as anything else will likely be
wrong. If that's not possible with the formatting library, you've already
lost; you'll have to completely correctly re-implement the formatting
library, and not only is that a major PITA, you almost never get it
bug-for-bug right...


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Max Francis  
View profile  
 More options May 5 2005, 4:43 pm
Newsgroups: comp.lang.python
From: Erik Max Francis <m...@alcyone.com>
Date: Thu, 05 May 2005 13:43:37 -0700
Local: Thurs, May 5 2005 4:43 pm
Subject: Re: How to detect a double's significant digits

Jeremy Bowers wrote:
> Step one for mrstephengross is to *rigorously* define what he means by
> "significant digits", then go from there. Since I think he mentioned
> something about predicting how much space it will take to print out, my
> suggestion is to run through whatever printing routines there are and get
> a string out, the measure the string, as anything else will likely be
> wrong. If that's not possible with the formatting library, you've already
> lost; you'll have to completely correctly re-implement the formatting
> library, and not only is that a major PITA, you almost never get it
> bug-for-bug right...

Especially since all of his examples have the same number of significant
digits (3), as the term is usually meant.  Zeroes to the right are
significant, not zeroes to the left.

--
Erik Max Francis && m...@alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   What is it that shapes a species?
   -- Louis Wu


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Grant Edwards  
View profile  
 More options May 5 2005, 10:45 pm
Newsgroups: comp.lang.python
From: Grant Edwards <gra...@visi.com>
Date: Fri, 06 May 2005 02:45:27 -0000
Local: Thurs, May 5 2005 10:45 pm
Subject: Re: How to detect a double's significant digits
On 2005-05-05, Erik Max Francis <m...@alcyone.com> wrote:

> Especially since all of his examples have the same number of
> significant digits (3), as the term is usually meant.  Zeroes
> to the right are significant, not zeroes to the left.

And only the person who performed the measurement knows how
many of the zeros to the right are significant.

--
Grant Edwards                   grante             Yow!  They don't hire
                                  at               PERSONAL PINHEADS,
                               visi.com            Mr. Toad!


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Grant Edwards  
View profile  
 More options May 5 2005, 10:44 pm
Newsgroups: comp.lang.python
From: Grant Edwards <gra...@visi.com>
Date: Fri, 06 May 2005 02:44:43 -0000
Local: Thurs, May 5 2005 10:44 pm
Subject: Re: How to detect a double's significant digits
On 2005-05-05, Jeremy Bowers <j...@jerf.org> wrote:

> Since I think he mentioned something about predicting how much
> space it will take to print out, my suggestion is to run
> through whatever printing routines there are and get a string
> out,

A step which will require him to tell the printing routine how
many digits he wants printed.

--
Grant Edwards                   grante             Yow!  FUN is never having
                                  at               to say you're SUSHI!!
                               visi.com            


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Grant Edwards  
View profile  
 More options May 5 2005, 10:46 pm
Newsgroups: comp.lang.python
From: Grant Edwards <gra...@visi.com>
Date: Fri, 06 May 2005 02:46:12 -0000
Local: Thurs, May 5 2005 10:46 pm
Subject: Re: How to detect a double's significant digits
On 2005-05-05, mrstephengross <mrstephengr...@hotmail.com> wrote:

>>This doesn't look like Python to me.  Are you sure you're on the right
> newsgroup?

> Er, ok, I'm an idiot. This was all supposed to be on
> comp.lang.c++, but obviously I posted on the wrong one. Sorry
> for all the hassle. In python, this stuff is a heck of a lot
> easier.

No, it isn't.  The question is equally meaningless in any
language.

--
Grant Edwards                   grante             Yow!  WHO sees a BEACH
                                  at               BUNNY sobbing on a SHAG
                               visi.com            RUG?!


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeremy Bowers  
View profile  
 More options May 5 2005, 11:02 pm
Newsgroups: comp.lang.python
From: Jeremy Bowers <j...@jerf.org>
Date: Thu, 05 May 2005 23:02:06 -0400
Local: Thurs, May 5 2005 11:02 pm
Subject: Re: How to detect a double's significant digits

On Fri, 06 May 2005 02:44:43 +0000, Grant Edwards wrote:
> On 2005-05-05, Jeremy Bowers <j...@jerf.org> wrote:

>> Since I think he mentioned something about predicting how much space it
>> will take to print out, my suggestion is to run through whatever
>> printing routines there are and get a string out,

> A step which will require him to tell the printing routine how many digits
> he wants printed.

Not necessarily; consider the str() of a float in Python, especially given
the "significant digits" aspect (it may be ill-defined, but I can think of
several well-defined ways to mean that, where str() embodies one of them).
The easiest way to tell how long the number will be when str prints it out
is to simply ask it.

In C++, this may be harder, as your output software may insist on
rendering everything directly, with no way to reach in and tell what it
did. Imagine the standard IOStreams, without the ability to stream into a
string. Now it's a lot harder to tell. So if you've got something "smart"
like the default str() in Python, you may not be able to tell in advance
what it is going to do, short of trying to manually reverse engineer it.
I've tried that a few times, and in each instance, I can get 95-99%... but
I never quite make it to 100%, usually because I find a bug somewhere and
can't figure out how to characterize and replicate it.

(The biggest of these so far was when I tried to reconstruct Tk's wrapping
in a text widget, so I could tell how many screen lines the given piece of
text I produced would consume, whereupon I discovered Tk didn't correctly
wrap all Unicode characters... it correctly (as far as I could see)
reported their widths, but happily let the characters run right off the
right edge of the widget under certain circumstances I could never
characterize without putting in even more effort than I cared to. The bugs
aren't always *important*, one can imagine the opposite problem of
wrapping a little too quickly, and it could be years before anyone notices
if it's just a few pixels off in the right direction, but it'll still
screw you up if you try to replicate it.)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Max Francis  
View profile  
 More options May 5 2005, 11:08 pm
Newsgroups: comp.lang.python
From: Erik Max Francis <m...@alcyone.com>
Date: Thu, 05 May 2005 20:08:46 -0700
Local: Thurs, May 5 2005 11:08 pm
Subject: Re: How to detect a double's significant digits

Jeremy Bowers wrote:
> Not necessarily; consider the str() of a float in Python, especially given
> the "significant digits" aspect (it may be ill-defined, but I can think of
> several well-defined ways to mean that, where str() embodies one of them).
> The easiest way to tell how long the number will be when str prints it out
> is to simply ask it.

Grant's point was that as significance is used in scientific studies,
there's no way to answer the question without having the number in
advance.  If I say that the length of something is 1100 m, you don't
know whether I mean 1.1 x 10^3 m, 1.10 x 10^3 m, 1.100 x 10^3 m, etc.
These all have different significances.  The figure 1100 m can't tell
you how many significance figures are involved without further information.

In particular, the example he gave involved changing significance
depending on the number of zeroes _before_ the other digits, not after
them, which is now how significance works.  So obviously when he says
"significant digits" he doesn't mean the same thing that's used by
scientists, so the question can't really be answered.

If he simply wanted to get the number of digits involved, then that's
fine, but that's not what significance is.

--
Erik Max Francis && m...@alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   Eternity is very long, especially near the end.
   -- Woody Allen


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dan Bishop  
View profile  
 More options May 5 2005, 11:10 pm
Newsgroups: comp.lang.python
From: "Dan Bishop" <danb...@yahoo.com>
Date: 5 May 2005 20:10:09 -0700
Local: Thurs, May 5 2005 11:10 pm
Subject: Re: How to detect a double's significant digits

Fredrik Lundh wrote:
> "mrstephengross" wrote:

> > >But, assuming you have your numbers as strings, I would suggest
> > looking
> > at str.split() and len().

> > Well, the numbers are in fact stored as numbers, so string
processing
> > won't work.

> if they're not strings, your question is meaningless.  as others have
> pointed out, the exact internal representation for 0.103 is more like
> 0.10299999999999999433786257441170164383947849273681640625
> which has a lot more than 3 digits...

Actually, it's more like

0 01111111011 1010010111100011010100111111011111001110110110010001


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeremy Bowers  
View profile  
 More options May 5 2005, 11:36 pm
Newsgroups: comp.lang.python
From: Jeremy Bowers <j...@jerf.org>
Date: Thu, 05 May 2005 23:36:05 -0400
Local: Thurs, May 5 2005 11:36 pm
Subject: Re: How to detect a double's significant digits

On Thu, 05 May 2005 20:08:46 -0700, Erik Max Francis wrote:
> Grant's point was that as significance is used in scientific studies,
> there's no way to answer the question without having the number in
> advance.

My point was that the original poster never defined "significance" in that
manner, and in the manner in which he seemed to be using the term, my
comments made sense. Which is why the first thing I said was he needs to
rigorously define what he means, and everything after that was predicated
on the assumption he seemed to be looking at consumed screen space.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 1 - 25 of 29   Newer >
« Back to Discussions « Newer topic     Older topic »

Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google