[Gambas-user] Financial program

Doriano Blengino doriano.blengino at ...1909...
Tue Dec 15 08:19:42 CET 2009


nando ha scritto:
> My contribution to this conversation is..
> Always INT or LONG for money.
> Keep a global variable to divide by (for example 2 decimal places) 100
> when printing/displaying things to humans...
> -OR- to take the string and insert a period for cents (North America)
> Make a really nice SUB to return a formatted string is good.
> It is the utmost importance not to use FLOAT from the beginning
> because calculations will be wrong after a while and it will not balance.
> You will have headaches!!!
>   
You are perfectly true. It seems that floating point does not like base 
10 numbers... :-)

But here comes in place the power of a programming language; a good 
language is a wrapper around bad or annoying things. All we love gambas 
because it is easy to construct user interface. But there would be no 
necessity of its power - one can write external functions and interface 
to X11 directly...

So when you tell me "don't use floats for accounting" I agree. When you 
say "use a global variable to divide", "insert a decimal point" and so 
on, I think "100% of gambas users want to use graphical interfaces, 
while only 2% of them want to use financial capabilities. So, that 2% 
must live with a language not very suitable for accounting". "Use long 
integers, divide them, use format$()..." is the reply from Benoit. Does 
someone remember the Cobol? With a simple declaration "picture 99.9999" 
it created a datatype and managed all the roundings and conversions on 
that datatype; this was the power of that language. I don't say that 
gambas should implement this, but it would not hurt... it is a matter of 
choice; I understand that this kind of things is difficult to implement 
(or, who knows... with OO programming... but the really hard part is the 
mixing of different types in the same expression).

The most important application I've written with gambas is something 
similar to a financial one. I faced problems with gridviews, tableviews, 
formats, roundings... all the things we are speaking about just now, and 
they are not yet fully solved. I think that the way you describe is a 
hard work, even if it is the only possible at the moment.

Regards,

-- 
Doriano Blengino

"Listen twice before you speak.
This is why we have two ears, but only one mouth."





More information about the User mailing list