Click here to Skip to main content
16,016,067 members
Home / Discussions / C#
   

C#

 
GeneralRe: float calculation issue Pin
George_George31-May-08 3:15
George_George31-May-08 3:15 
GeneralRe: float calculation issue Pin
The Nightcoder2-Jun-08 2:35
The Nightcoder2-Jun-08 2:35 
GeneralRe: float calculation issue Pin
George_George3-Jun-08 1:59
George_George3-Jun-08 1:59 
GeneralRe: float calculation issue Pin
The Nightcoder3-Jun-08 2:39
The Nightcoder3-Jun-08 2:39 
GeneralRe: float calculation issue Pin
George_George3-Jun-08 2:51
George_George3-Jun-08 2:51 
GeneralRe: float calculation issue Pin
The Nightcoder3-Jun-08 3:18
The Nightcoder3-Jun-08 3:18 
GeneralRe: float calculation issue Pin
George_George3-Jun-08 21:57
George_George3-Jun-08 21:57 
GeneralRe: float calculation issue Pin
The Nightcoder4-Jun-08 2:55
The Nightcoder4-Jun-08 2:55 
Hi!

Now you're starting to get really interesting... Smile | :)

1. I'm not competent enough with maths these days (I used to be an assistant teacher in numerical analysis, but that was almost 30 years ago) to either agree or disagree. I suspect you may be right, though, and I suspect it may be related to the fact that 10 is a multiple of 2. That is, binary 0.1 is representable as decimal 0.5, from which would follow that all values that can be represented with a finite number of binary digits should be representable with a finite number of decimal digits as well. But again, this is a guess, not a fact...

2. Again, I suspect you are right. Then again - there are an infinite number of values with an infinite number of decimals (or that require a larger number of digits to be exactly represented than any of the precisions we use - whether double, float or decimal) regardless of base, and there are many calculations that can cause such values to appear. So: Rounding problems will occur in any case, whether we use binary or decimal.

However, when dealing with monetary calculations decimal has an advantage in that it behaves the way a financial calculator does - so it causes fewer surprises for accountants... Smile | :) Then again, you can accomplish the same by carefully using rounding with, say, double.

Peter the small turnip

(1) It Has To Work. --RFC 1925[^]

GeneralRe: float calculation issue Pin
George_George4-Jun-08 22:31
George_George4-Jun-08 22:31 
GeneralRe: float calculation issue Pin
The Nightcoder4-Jun-08 23:08
The Nightcoder4-Jun-08 23:08 
GeneralRe: float calculation issue Pin
George_George4-Jun-08 23:28
George_George4-Jun-08 23:28 
AnswerRe: float calculation issue (decimal is no solution) [modified] Pin
The Nightcoder28-May-08 23:12
The Nightcoder28-May-08 23:12 
GeneralRe: float calculation issue (decimal is no solution) Pin
George_George31-May-08 3:28
George_George31-May-08 3:28 
GeneralRe: float calculation issue (decimal is no solution) Pin
The Nightcoder2-Jun-08 3:02
The Nightcoder2-Jun-08 3:02 
GeneralRe: float calculation issue (decimal is no solution) Pin
George_George3-Jun-08 2:09
George_George3-Jun-08 2:09 
GeneralRe: float calculation issue (decimal is no solution) Pin
The Nightcoder3-Jun-08 2:48
The Nightcoder3-Jun-08 2:48 
GeneralRe: float calculation issue (decimal is no solution) Pin
George_George3-Jun-08 3:00
George_George3-Jun-08 3:00 
GeneralRe: float calculation issue (decimal is no solution) Pin
The Nightcoder3-Jun-08 3:37
The Nightcoder3-Jun-08 3:37 
GeneralRe: float calculation issue (decimal is no solution) Pin
George_George3-Jun-08 21:53
George_George3-Jun-08 21:53 
GeneralRe: float calculation issue (decimal is no solution) Pin
The Nightcoder4-Jun-08 3:04
The Nightcoder4-Jun-08 3:04 
GeneralRe: float calculation issue (decimal is no solution) Pin
George_George4-Jun-08 22:22
George_George4-Jun-08 22:22 
GeneralRe: float calculation issue (decimal is no solution) Pin
The Nightcoder4-Jun-08 23:01
The Nightcoder4-Jun-08 23:01 
GeneralRe: float calculation issue (decimal is no solution) Pin
George_George4-Jun-08 23:27
George_George4-Jun-08 23:27 
GeneralRe: float calculation issue (decimal is no solution) Pin
The Nightcoder5-Jun-08 4:01
The Nightcoder5-Jun-08 4:01 
GeneralRe: float calculation issue (decimal is no solution) Pin
George_George5-Jun-08 14:48
George_George5-Jun-08 14:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.