Log in

View Full Version : Decimals in Simba?



Ian
10-08-2012, 06:07 PM
For a progress report, I need to multiply something by a decimal to get an amount of xp/h. The only problem is the xp/item (bones) is 4.5 I kept getting a type mismatch error until I thought "maybe it was the decimal". I changed 4.5 to 4 and it worked. Now I just want to know if there is a way to get it to multiply 4.5 . The only thing I can think of is this: X(4 + (1/2))
Any other ideas?

With decimals (doesn't work):
WriteLn('~XP earned:' + IntToStr(Bones *4.5) + '(' + IntToStr(XPPH) + ' P/H)~');

With fractions (works):
WriteLn('~XP earned:' + IntToStr(Bones * (4 + (1/2))) + '(' + IntToStr(XPPH) + ' P/H)~');

masterBB
10-08-2012, 06:14 PM
Replace IntToStr with ToStr.

also fractions don't work since it will round the answer.

Ian
10-08-2012, 06:20 PM
Replace IntToStr with ToStr.

also fractions don't work since it will round the answer.

Ah thank you :D, int does mean integer after all doesn't it. Will it round it with ToStr?

BraK
10-08-2012, 06:22 PM
with decimals you have to use extended instead of integer.

Ian
10-08-2012, 06:24 PM
with decimals you have to use extended instead of integer.

is it ExtToStr?

Kasi
10-08-2012, 06:30 PM
FloatToStr

Edit: Ninja'd a Jedi.
Edit2: Also want to wipe my mind?! Just while your at it.

BraK
10-08-2012, 06:30 PM
StrtoFloat and FloattoStr

Ninja'd Thinking of wiping the post with my jedi powers.

Ian
10-08-2012, 06:33 PM
Thanks both of you :p

masterBB
10-08-2012, 07:48 PM
IntToStr(Round(Bones *4.5))