[Gambas-user] About financial program in Gambas

Benoît Minisini gambas at ...1...
Wed Dec 16 00:17:55 CET 2009


Wow, what a big talk...

I just want to explain a few points.

1) I didn't say that I don't want to implement a currency or fixed decimal 
datatype in Gambas 3. I just can't. The maximum number of native datatypes has 
been reached the way the datatype system works. So it needs a good bit of 
redesign in the interpreter. Think to the datatype conversion functions, that 
must be able to convert any datatype to any other. Its size is almost 
proportional to the square of the number of datatypes. All arithmetic 
functions must deal with all datatypes. And so on... I wanted to keep the 
interpreter small, so adding these features was never a priority.

2) In some languages, the datatype has a meaning in the way the data in stored 
in memory *and* in the way the data must be display on the screen. But not in 
Gambas. This is the reason I don't like declaration of fixed floating point 
values, that are just integers with a special multiplication and division.

3) Why nobody starts writing a Decimal class whose objects are fixed floating 
point values, with a lot of financial methods? That beast can be written in 
Gambas first, and then converted to a C component easily, as no library is 
needed to perform all the computation. But maybe using a already existing 
financial library is a better idea then.

4) Floating point values are computed in base 2. And, in base 2, 1/10 is like 
1/3 in base 10. You cannot represent it with a finite precision. So:

	1.4 - 0.2 = 1.200000047684

is perfectly valid with a Single datatype. You get the real value stored in 
memory.

Regards,

-- 
Benoît Minisini




More information about the User mailing list