Special float values

Will Coleda will at coleda.com
Wed Nov 26 16:09:36 UTC 2008


On Wed, Nov 26, 2008 at 10:55 AM, jerry gay <jerry.gay at gmail.com> wrote:
> On Wed, Nov 26, 2008 at 07:46, Will Coleda <will at coleda.com> wrote:
>> On Wed, Nov 26, 2008 at 10:42 AM, François Perrad
>> <francois.perrad at gadz.org> wrote:
>>>
>>> in languages/lua/src/lib/mathx.pir, I want create numbers with special
>>> value (NaN & Infinity), something like :
>>>
>>>   new $P0, 'Float'      # or 'LuaNumber'
>>>   set $N0, 'NaN'
>>>   set $P0, $N0
>>>   say $P0
>>>
>>> Is it possible ?
>>>
>>> François.
>>
>> I don't know about inf, but yes, nan works:
>>
>> .sub main
>>  $N0 = 'nan'
>>  if $N0 != $N0 goto ok1
>>  print 'not '
>> ok1:
>>  say 'ok 1'
>>
>>  $P0 = new 'Float'
>>  $P0 = $N0
>>  if $P0 != $P0 goto ok2
>>  print 'not '
>> ok2:
>>  say 'ok 2'
>>
>> .end
>>
> i have a feeling that's os-dependent. msvc produces:
> not ok 1
> not ok 2
>
> ~jerry
>

Probably the same "nan is platform dependent" issues we've had for
some time, yes. This sample passes for me on osx/86 and feather.

-- 
Will "Coke" Coleda


More information about the parrot-dev mailing list