Microsoft
Software
Hardware
Network
Question : Subtracting 2 Numbers Problem
I am trying to subtract 2 numbers; the numbers come from different sources (one from the Internet, the other from a table in a database where its type is decimal.
If they both have the same value, when I try to subtract them, I get a result like 7.105427357601e-015. I tried casting to int (.to_i) and it works fine but I lose the decimal part. If I cast them to float I get a similar result to that given above. I cannoy think of any other cast to make.
Another thing if the two numbers are 84.21 and 80.21, the difference is 3.9999999999999
Subtracting 84.21 from 80.18 produces the correct value.
Sometimes I despair.
Can anyone help?
Answer : Subtracting 2 Numbers Problem
Yep, I spotted the error
please look at my last comment
Random Solutions
Reliable method for calculating disk usage
ISAPI Authentication Filter
Is it Possible in Exchange 2007 to Globally change certain values?
Multiple AJAX calls / request at Ruby on Rails
PowerShell script to create/update/delete in Windows 2003 AD via csv file
XP - CD Burn backup using command line script
Flash - Pause for 10 seconds
Subtract two currency MERGEFIELDs in MS mail merge
How do i get hyperlinks to open in a new tab?
Public Folders do not show in Exchange Management Console