'int' object gives different results when receiving -inf between Mac OSX and Windows (maxm

Mar 14, 2006 at 10:07am

'int' object gives different results when receiving -inf between Mac OSX and Windows (maxm

Hi,

I found a different behaviour between OSX and Win for int object.
When it receives float -infinity :
* on OSX, returns minimal integer : -2147483648
* on Win, returns zero

The behaviour on windows is buggy, float -infinity cannot be int zero.

-inf is obtained by sending zero to atodb. (So my custom vumeters, which
are working fine on OSX are broken on windows)

the problem is the same for int box number.

Best regards,
Chris

NB: see below simple patch to test this

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P message 325 54 14 196617 1;
#P number 222 152 79 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 186 152 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 204 130 27 196617 float;
#P message 306 54 14 196617 0;
#P newex 306 79 31 196617 atodb;
#P flonum 306 99 105 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 306 152 116 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 306 133 27 196617 int;
#P connect 5 0 6 0;
#P connect 2 0 5 0;
#P connect 5 0 7 0;
#P connect 4 0 3 0;
#P connect 8 0 3 0;
#P connect 3 0 2 0;
#P connect 2 0 0 0;
#P connect 0 0 1 0;
#P window clipboard copycount 9;

#24874
Mar 14, 2006 at 11:35am

The obvious suspect is differences in the implementation of IEEE 754
at either the level of mathlib.c, the OS, or the processor. So it’s
not as if it’s directly Max’ “fault”.

Still, Max’ developers seem to take pride in its cross-platform
compatibility, and it would be a Good Thing if the idiosyncrasies of
Mac vs. Windows implementations of IEEE 754 could be overcome.

I don’t know off-hand what IEEE 754 specifies when typecasting float
infinities to integer. I think min/max int values are the most
logical (i.e., what happens on Mac OS).

– Peter

————– http://www.bek.no/~pcastine/Litter/ ————-
Peter Castine | +–> Litter Power & Litter Bundle for Jitter
|…………………………………………….
p@castine.de | iCE: Sequencing, Recording, and Interface Building
pcastine@gmx.net | for Max/MSP
pcastine@bek.no | http://www.dspaudio.com/ Extremely cool
4-15@kagi.com |…………………………………………….
| home|chez nous|wir|i nostri http://www.castine.de/

#72530
Mar 14, 2006 at 2:19pm

i would not have known the details peter knows,
but would have guessed the same: calculation
in MAX uses mathlib, so it is a mathlib issue.

maybe it is not even a windows mathlib error,
we could call it a mac os bug as well, int isn t
exactly a number isn t it? we should not exspect
to display number box anything else than numbers,
it will not display pi, and we can not exspect it
to display inf. :)

it is a great service already than numbox displays
NaN where neccessary.

#72531
Mar 14, 2006 at 9:11pm

number box is one part of the problem, but “int” object is another.
it should pass a value to outlet indicating an approximation of -inf.
for int, the best is -2147…..

I guess the problem is the same with +inf.

Chris

#72532
Mar 14, 2006 at 10:12pm

Thanks Chris,

I think it should work the way it does on the Mac too.

-A

#72533
Mar 15, 2006 at 8:17am

> I think it should work the way it does on the Mac too.
yes, this is the main point, to have cross plateform compatible patchs.

Chris

#72534
Mar 16, 2006 at 4:41pm

OK, here’s the deal.

This issue is processor specific. The feeling among the developers is that if the c language doesn’t take a stand on this then it may be for some good reason. The conversion should be treated as undefined and worked around with something like this

#P window setfont “Fixedwidth Serif” 12.;
#P flonum 141 222 44 12 0 0 0 141 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 177 300 15 0;
#P toggle 58 313 15 0;
#P window linecount 1;
#P newex 175 267 99 9240588 > 2147483648.;
#P newex 56 259 106 9240588 < -2147483648.;
#P message 118 151 36 9240588 -1.;
#P message 69 152 29 9240588 1.;
#P newex 82 192 36 9240588 / 0.;
#P connect 0 0 3 0;
#P connect 0 0 7 0;
#P connect 0 0 4 0;
#P connect 4 0 6 0;
#P connect 3 0 5 0;
#P connect 2 0 0 0;
#P connect 1 0 0 0;
#P window clipboard copycount 8;

Cheers

-A

#72535

You must be logged in to reply to this topic.