Double data type

Started by pcj, Fri 16/01/2004 22:13:38

Previous topic - Next topic

pcj

Is there any way to add the double data type so we can use decimals in our calculations?

By the way, when a decimal value is left over in a calculation in AGS, does it round up or down?

Thanks.
Space Quest: Vohaul Strikes Back is now available to download!

a-v-o

There is a plugin for floating point numbers and calculations.

I think there aren't many cases in which you need decimals. You can store fractions in 2 integers: a multiplier integer and a divisor integer.


Frogman_

"By the way, when a decimal value is left over in a calculation in AGS, does it round up or down?"

I think it rounds down.

pcj

I really don't want a plugin; I'd like a data type.  It'd just be a lot easier to use decimals in my calculations instead of working around it.

Especially when working with leap years.
Space Quest: Vohaul Strikes Back is now available to download!

Dorcan

Why not multiplying all the numeric values by 1000 for exemple ? When the calculation is finished, just divise the result by 1000...

pcj

Wouldn't it round off the decimal before the calculation, though?
Space Quest: Vohaul Strikes Back is now available to download!

Pumaman

Adding floating point numbers would mean quite a hefty amount of rework to the script compiler, and I'm not really sure that it's worth it considering how rarely they are needed.

As Dorcan suggests, you can emulate 3 decimal points of precision by multiplying all the parameters by 1000, and then dividing the result by 1000 afterwards.

pcj

Space Quest: Vohaul Strikes Back is now available to download!

SMF spam blocked by CleanTalk