dear list
I know pd is working with 32bit floats.
1.question 1.4 - int(1.4) = something like 0.39999999999999999999999999999 is this the way pd calculate?
2.question is there a way to check the result with [== 0.4] which outputs 1?
3.question is 0.4 in [== 0.4] a 32bit float?
thank you and have a nice weekend!
eni
1.question 1.4 - int(1.4) = something like 0.39999999999999999999999999999 is this the way pd calculate?
i guess, you want to write 1.4 - int(1) ... floating point math is not associative, so 1.4 - 1 - 0.4 != 0 see: http://en.wikipedia.org/wiki/Floating_point#Properties_of_floating_point_ari...
2.question is there a way to check the result with [== 0.4] which outputs 1?
3.question is 0.4 in [== 0.4] a 32bit float?
no, because there is no possibility to encode 0.4 as a floating point number without rounding ... an equality test only makes sense, if a number can be encoded as floating point number and it's sure, you're experiencing rounding problems ...
hth ... tim
-- TimBlechmann@gmx.de ICQ: 96771783 http://www.mokabar.tk
Happiness is a byproduct of function, purpose, and conflict; those who seek happiness for itself seek victory without war. William S. Burroughs
hi tim, eni
"Tim Blechmann" wrote:
no, because there is no possibility to encode 0.4 as a floating point number without rounding ... an equality test only makes sense, if a number can be encoded as floating point number and it's sure, you're experiencing rounding problems ...
of course, it is a rounding problem. but the fact, that some objects in some cases are rounding up ([print], [numberbox], [msgbox]) and others down ([int]) makes the story more complicated, see attached patch. it could be annoying sometimes, since represantion differs from effective values. what is a good solution for handling with this? insert a [+ 1e-006]?
roman
Thanks Tim and Roman for your help
I'll try [+ 1e-006]
On Mar 25, 2006, at 7:30 PM, Tim Blechmann wrote:
1.4 - int(1.4) = something like 0.39999999999999999999999999999 is this the way pd calculate?
i guess, you want to write 1.4 - int(1) ...
actually i wanted to express
[1.4( | [int]
Hallo, Enrique Erne hat gesagt: // Enrique Erne wrote:
Thanks Tim and Roman for your help
I'll try [+ 1e-006]
This is no solution. You just cannot use [==] to compare non-integer floating point values so easily, period. A better approach is to multiply with 10^x up to your desired range. See attached patch titled: "The good, the bad, and the ugly"
Frank Barknecht _ ______footils.org_ __goto10.org__
thank you frank!
On Mar 26, 2006, at 1:25 PM, Frank Barknecht wrote:
Hallo, Enrique Erne hat gesagt: // Enrique Erne wrote:
Thanks Tim and Roman for your help
I'll try [+ 1e-006]
This is no solution. You just cannot use [==] to compare non-integer floating point values so easily, period. A better approach is to multiply with 10^x up to your desired range. See attached patch titled: "The good, the bad, and the ugly"
:-)
Ciao
Frank Barknecht _ ______footils.org_ __goto10.org__ <float-comparison.pd>_______________________________________________ PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
On Sun, 26 Mar 2006, Enrique Erne wrote:
1.4 - int(1.4) = something like 0.39999999999999999999999999999 is this the way pd calculate?
i guess, you want to write 1.4 - int(1) ...
int(1) and int(1.4) are both equal to exactly 1.
1.4 - int(1.4) != 0.4 because floats aren't decimal, they are binary, so you can't write tenths, you can only write halves, quarters, eighths, sixteenths, and so on.
Thanks Tim and Roman for your help I'll try [+ 1e-006]
With that you'll get more than 0.4. Floats have more than 6 decimal digits (they have 24 binary digits). Try this:
[1.4( | [- 1] | [- 0.4] | [print]
I get this: -2.98023e-08
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801 - http://artengine.ca/matju | Freelance Digital Arts Engineer, Montréal QC Canada
On Mar 25, 2006, at 7:30 PM, Tim Blechmann wrote:
3.question is 0.4 in [== 0.4] a 32bit float?
no, because there is no possibility to encode 0.4 as a floating point number without rounding ... an equality test only makes sense, if a number can be encoded as floating point number and it's sure, you're experiencing rounding problems ...
wouldn't it make sense if the 0.4 in [== 0.4] got encoded _with_ rounding? I mean that _all_ numbers in pd get encoded _with_ rounding.
or is there an advantage that i.e. the number in [==] is not a 32bit float ?