View Single Post
Author Message
Geesu
Veteran Member
Join Date: Mar 2004
Location: Cincinnati, OH
Old 11-08-2006 , 15:51   #define val 1.05 is actually 1.049999 ?
Reply With Quote #1

So basically I have this:

Code:
#define ITEM_BOOT_INCREASE    1.05                    // Represents % increase

And I do a little math later:

( ( ITEM_BOOT_INCREASE - 1.00 ) * 100.00 )

Which (in theory) is 5.

But when doing client_prints and checking the results:

Code:
client_print( id, print_chat, "(%f - %f) * %f = %0.0f", ITEM_BOOT_INCREASE, 1.00, 100.00, ( ( ITEM_BOOT_INCREASE - 1.00 ) * 100.00 ) );

This presents the output:
Code:
(1.049999 - 1.000000) * 100.000000 = 4

Why is 1.05 represented as 1.049999 ? And how do I get it to be 1.05?

Thanks,
Josh
__________________
Need war3ft help? DO NOT PM ME... Check the forums
Geesu is offline
Send a message via AIM to Geesu Send a message via MSN to Geesu