Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Why not 1*(0.5-0.4-0.1) = 0?
Message
De
07/01/2005 04:04:56
 
 
À
06/01/2005 23:34:32
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Database:
MS SQL Server
Divers
Thread ID:
00974881
Message ID:
00974988
Vues:
48
This will probably end up as a discussion on definitions, and if so I'm out of here! :-)

What I am saying, is that any integer has a defined binary value, like 0=0, 1=1, 2=10, 3=11, 4=100 and so on. So for integers they don't need a 100 pages standard. For decimals it does not work that way, so they have different standard, like IEEE standards, to define how to express them binary. I am far from an expert on this issue, but I know that no matter how you convert a decimal into binary, there is room for errors. On some systems you can specify the accuracy, let's say to 20 decimals, but internally most (all?) of those systems then simply multilpy the values by 10^20, and divide the result by 10^20. You don't overcome the problem completely, but for most calculations you will get the mathematically correct value.


>>With ANY decimal numbers you will have some rounding errors. Sometimes the programs masks the error, and you get the result you want, and sometimes you get the wrong value, there's simply no way to avoid that.
>
>Not quite correct. The following set of decimals (plus any integer part) has an exact representation in binary: 0.5, 0.25, 0.75, 0.125, 0.375, 0.625, 0.875, ... i.e. those that can be expressed as m/2**n.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform