Friday, January 13, 2006

A Careful Balancing Act - The Daily WTF: "It is, sort of. Anyone who uses a float value to represent money in an accounting app should be fired immediately. However, what you use instead is usually a 'big decimal' data type that can represent numbers of arbitrary length and precision with an explicitly specified number of fractional digits. This is usually implemented by an array of ints to hold the data and another int to say how many fractional digits to keep. That way, you can use the same code for things like exchange rates, where you need a higher number of fractional digits, and don't have to worry about overflows."

0 Comments:

Post a Comment

<< Home