lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


René Rebe <rene@exactcode.de> writes:

> David Kastrup wrote:
>> Asko Kauppi <askok@dnainternet.net> writes:
>>
>>   
>>> Some weeks ago, I had a hard disk problem that basically wiped out my
>>> accounting software (last Windows application I was using). About
>>> time.
>>>
>>> I considered the options (€ 300 upgrade for the same software) and
>>> decided to just do it with Lua.
>>>
>>> This is only for my own usage (as Linux was for Linus...) but I'd like
>>> to hear if anyone else is using Lua for their SOHO business or
>>> personal finances.
>>>
>>> I'm using Lua as the data description language for transactions (no
>>> database), and some hundreds of lines of "main code" create reports
>>> for monthly and yearly taxation.  Printing bills using LuaCairo (into
>>> PDF) will be the next stage, and there I shall stop.
>>>     
>>
>> Well, there is the obvious advice: do the accounting in cents, not in
>> dollars.  Lua can represent multiples of 1 exactly, but not multiples of
>> 0.01.  So if you are doing your calculations in dollars, at some point
>> of time the cents will not add up properly.
>>   
> And this also only up to 2^32,

More like 2^52.  Lua does not use integers as an internal data type, so
the relevant limit is the mantissa size of floating point numbers.  And
even 2^31 would be sufficient for 10 million dollars when calculating in
cents.  2^52 cents should carry you through to something like 45
trillion dollars.

> ... which is why spread-sheet apps and other serious accounting stuff
> uses bignum libraries ...

Well, if 45 trillion is not a suitable limit for your financial needs,
you are either pessimistic about inflation or I want to have your baby.
For ransoming, of course.

-- 
David Kastrup