[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Biggest Number
- From: Coda Highland <chighland@...>
- Date: Thu, 31 Aug 2017 14:57:08 -0500
On Thu, Aug 31, 2017 at 2:39 PM, Matthias Dörfelt <firstname.lastname@example.org> wrote:
> in C++ I often times use idioms like:
> auto shortestDistance = std::numeric_limits<float>::max()
> // …
> for(auto item : list)
> float dist = determineDistance(item);
> if(dist < shortestDistance)
> // ...
> shortestDistance = dist;
> // …
> After browsing for a while I could not find any similar constant to std::numeric_limits<float>::max() to get the biggest available number in lua. Is there one? If not, is there a reliable way to build my own function/constant?
Lua uses double-precision floating-point numbers by default. The
largest value of that data type is 1.7976931348623157e+308.
That said, an even better choice would be positive infinity, which
isn't exactly a "value" inasmuch as you can't do math on it, but it
compares greater than any other numeric value. This is available via