[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How do I say a = inf in Lua?
- From: "Matthew Wild" <mwild1@...>
- Date: Tue, 16 Dec 2008 18:18:12 +0000
On Tue, Dec 16, 2008 at 6:13 PM, Daniel van Ham Colchete
<daniel.colchete@gmail.com> wrote:
> Hi yall!
>
> I've been doing some tests with infinite numbers. I couldn't find a reserved
> keyword for the infinite or minus infinite numbers. But, when Lua is using
> double floatint point as the number type they work. I just have to use
> something I know from the hardware: that 1e309 is infinite in double and
> that -1e309 is minus infinite in double precision. Look at some tests:
>
>> big = 1e309
>> small = -1e309
>> print(big, small)
> inf -inf
>> print ( 0 > big, -1 > big, 1 > big)
> false false false
>> print ( 0 > small, -1 > small, 1 > small)
> true true true
>> print (small > big)
> false
>> print (big > small)
> true
>
> So, it works the way it should. My question is related to the fact that
> 1e309 is not the most beautiful way of saying "inf". Is there any other way?
> Altough "print(big)" will say "inf" I can't do just "big = inf". So, when
> somebodyelse is reading my code he is going to ask: what the fudge is 1e309?
> Why can't it be 2e309 or 1e308? 1e308 doesn't work because it is not
> infinite yet.
>
> Just a small joke: "Do you know what number is bigger than any other number?
> 1e309". He he, just made this one.
>
> I searched on Google, PIL and the list archive (since I joined) first.
>
http://www.lua.org/manual/5.1/manual.html#pdf-math.huge is likely what
you are looking for.
Matthew.