🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.interbase.sql
Article #775

Re: Float with too many decimals

#775
From: WillR
Date: Sun, 01 Jul 2007 12:34
30 lines
2159 bytes
Moore wrote:
> in a float field when i write 3,2 it shows 3,20000004768372
> why and what is the best solution for this???

Use a double. That's what I did. Otherwise you have to control the 
display of the numbers using edit masks and so on in the client program.

If you wonder why you are getting this result look up the formats for 
floating point and double numbers etc. in the IEEE specs -- for example.

Simplistic explanation... The float format is an approximation of most 
floating point numbers and does not have enough guard digits to "throw 
away" the spurious decimals. A float is expressed as a mantissa and 
exponent that are too low in precision (# of digits) to provide the 
accuracy (correctness) you wish to see.


http://www.google.ca/search?hl=en&q=IEEE+Float+double+specification&btnG=Search&meta=

The float type can represent values ranging from approximately 1.5 × 
10-45 to 3.4 × 1038 with a precision of 7 digits.

The double type can represent values ranging from approximately 5.0 × 
10-324 to 1.7 × 10308 with a precision of 15-16 digits.


-- 
Will R
PMC Consulting
Technical Details
Message-ID: <46879f33$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!feeder.news-service.com!194.25.134.62.MISMATCH!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <46878841$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,823fa3f99bdcc523
X-Google-Attributes: gid114a0e,public,usenet
X-Google-Language: ENGLISH,ASCII
Date: Sun, 01 Jul 2007 08:34:55 -0400
From: WillR <willrNo.Spam.pmccl.noSpam.com>
User-Agent: Thunderbird 1.5.0.12 (Windows/20070509)
MIME-Version: 1.0
Newsgroups: borland.public.interbase.sql
Subject: Re: Float with too many decimals
References: <46878841$1@newsgroups.borland.com>
In-Reply-To: <46878841$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable
NNTP-Posting-Host: 74.115.165.32
Message-ID: <46879f33$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1183293235 74.115.165.32 (1 Jul 2007 05:33:55 -0700)
Lines: 30
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!feeder.news-service.com!194.25.134.62.MISMATCH!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail