need currecy function

Blitz3D Forums/Blitz3D Programming/need currecy function

Zooker(Posted 2005) [#1]
I am re writing a check register program. Blitz does not have a currency function. Could I just use floats in place
of a currency function? Personal checks probably won't be made for more then a million(A wild guess) I intend to limit the decimal place to 2 places. Any ideas?

I'm 75 years old an as sharp ,as the head end of a Tack!


Dreamora(Posted 2005) [#2]
Yes you could use float instead.
But for the entry of the value you better use a string because you can enforce the 2 places decimal without much problem with the string commands. And the backparsing isn't hard with

value# = val(left(check,len(check)-3)) + val(right(check,2))/100.0

where check is the string which represents the value entered


Banshee(Posted 2005) [#3]
Could I just use floats in place
of a currency function?

Repeat after me: I will *NOT* use floats in a financial program. I will *NOT* use floats in a financial program. I will *NOT* use floats in a financial program...

Floats are great, courtesy of the FPU they work quicker than integers, they can hold obscure values which is brilliant for delta timing and 3D work, but the value held in the variable is an estimated value only.

Let me repeat the important bit here: "ESTIMATED" value only.

Now let's get back to our solemn pledge: I will *NOT* use floats in a financial program...

I personally would hold the data as an integer multiplied by 100 and I would do all entry and display as a string so I can add/remove commas and dots.


Shifty Geezer(Posted 2005) [#4]
I second Becky Rose's suggestion. Record values in cents/pence, not dollars/pounds, and just format the figure to LOOK like dollars+cents or pounds+pence.