SRL Archive - Help

Decimals in Simba?


Ian

2012-10-08 14:07:33

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

2012-10-08 14:14:43

Replace IntToStr with ToStr.

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

Ian

2012-10-08 14:20:58

From: masterBB
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

2012-10-08 14:22:26

with decimals you have to use extended instead of integer.

Ian

2012-10-08 14:24:19

From: BraK
with decimals you have to use extended instead of integer.


is it ExtToStr?

Kasi

2012-10-08 14:30:26

FloatToStr

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

BraK

2012-10-08 14:30:33

StrtoFloat and FloattoStr

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

Ian

2012-10-08 14:33:17

Thanks both of you :p

masterBB

2012-10-08 15:48:07

IntToStr(Round(Bones *4.5))