[PD] numbers seem to be wrongly adding up

Roman Haefeli reduzent at gmail.com
Wed May 19 13:51:27 CEST 2021



On Wed, 2021-05-19 at 13:38 +0200, rolfm at dds.nl wrote:
> 
> the value that should be 0.1250 is actually 0.1249999
> 
> and 0.75 is actually 0.7499994.

The intricacies of 32bit floating point numbers have been discussed up
and down on this list.

tldr; many decimal numbers do not have an exact floating point
representation. Incrementing with such numbers increases the error on
each iteration

Suggestion: Count with integer numbers and scale afterwards.

Roman
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20210519/66830673/attachment.sig>


More information about the Pd-list mailing list