in reply to Floating point problems
I really appreciate everybody's opinion here, really do. I've try other languages and they all have the same behaviour:
Smalltalk:Python:(0.6 / 0.2) asInteger 2
Ruby:python -c 'print int(0.6/0.2)' 2
ruby -e 'print (0.6/0.2).to_i' 2
In the end I believe Dynamic languages ( perl, ruby, python ) should handle cases like this in a more elegant and seamless way.
Dynamic languages do a pretty job hiding the internal representation of numbers for the user, in the sense that you can create program without knowing whether a variable holds an integer, double, float, fixed precision or any other representation. We leave the details of picking the right representation to the compiler/interpreter, so we (users) could expect to handle such border cases also seamlessly.
As a final though,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Floating point problems
by lidden (Curate) on Oct 24, 2010 at 16:13 UTC |