[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Integer division
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 21 Nov 2012 09:45:52 -0200
> How hard will it be to ensure that all the computations inside a given
> collection of functions are being done with floating point math? I have a
> library for generating parametric paths, and I know all of its internal
> computations ought to be floating point -- both for reasons of speed and
> precision handling. Will I need to explicitly convert any numeric
> arguments sent to that library to the float subtype? Something like:
>
> function path(x,y)
> return internal_path( tofloat(x), tofloat(y) )
> end ?
Yes, or this:
function path(x,y)
x = x/1; y = y/1; -- ensure 'floatness'
...
end
Moreover, you should write all your constants with a decimal mark (0.0,
1.0, etc.), which may be a good idea even in current Lua when you are
coding floating-point computations.
-- Roberto