Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: pcj on Fri 16/01/2004 22:13:38

Title: Double data type
Post by: pcj on Fri 16/01/2004 22:13:38
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.
Title: Re:Double data type
Post by: a-v-o on Fri 16/01/2004 22:57:57
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.

Title: Re:Double data type
Post by: on Fri 16/01/2004 23:02:36
"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.
Title: Re:Double data type
Post by: pcj on Sat 17/01/2004 00:35:34
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.
Title: Re:Double data type
Post by: Dorcan on Sat 17/01/2004 01:07:37
Why not multiplying all the numeric values by 1000 for exemple ? When the calculation is finished, just divise the result by 1000...
Title: Re:Double data type
Post by: pcj on Sat 17/01/2004 01:35:52
Wouldn't it round off the decimal before the calculation, though?
Title: Re:Double data type
Post by: Pumaman on Sat 17/01/2004 12:39:32
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.
Title: Re:Double data type
Post by: pcj on Sat 17/01/2004 13:45:04
Great, ok.  Thanks.