realbasic-nug
[Top] [All Lists]

Re: double to string????

To: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Subject: Re: double to string????
From: Harrie Westphal <harriew@frontiernet.net>
Date: Mon, 30 Jun 2008 14:22:11 -0500
Authentication-results: mx.google.com; spf=neutral (google.com: 74.124.194.228 is neither permitted nor denied by best guess record for domain of realbasic-nug-bounces@lists.realsoftware.com) smtp.mail=realbasic-nug-bounces@lists.realsoftware.com
Delivered-to: listarchive@realsoftware.com
In-reply-to: <C48EFA56.4EB33%markus_winter@online.de>
References: <C48EFA56.4EB33%markus_winter@online.de>
Reply-to: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Sender: realbasic-nug-bounces@lists.realsoftware.com

On Jun 30, 2008, at 2:02 PM, Markus Winter wrote:

I think a double should easily hold a 20 digit number. Otherwise it would be
the worst implementation in any programming language ever.

Markus,

You have to remember that with a 8 byte floating point number only 53 bits of the 64 bits hold the digits of the number. 11 bits are needed to hold the exponent of the number. Because of this an 8 byte UInt64 value can return more digits than an 8 byte, double, floating point number. However, the floating point exponent can take you out to powers of 308 or something like that which gives much larger numbers than integer can represent; but, you have a limit of 17 digits in a double.

Here is a good article that explains some of the oddities of floating point number. The author is primarily discussing 4 byte, single, floating point in Fortran but the same thing is going on in RB with floating point numbers. This same article also gives good examples of why floating point arithmetic can lead to unexpected problems if you have no understanding of what is going on internally.

http://www.lahey.com/float.htm

=== A Mac addict in Tennessee ===


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>