 |
haiku Wanderer
Joined: 19 Nov 2004 Posts: 70
|
Posted: Sat Aug 11, 2007 6:18 pm
question about #math/#VAR |
This wasn't working for me, so I started doing some debugging.
Here's the trigger.
#VAR xpToLevel %1
#VAR tempXpValue (@xpIntoLevel + @xpToLevel)
#VAR PercentThroughLevel (@xpIntoLevel / @tempXpValue)
#SHOW xpIntoLevel: @xpIntoLevel
#SHOW xpToLevel: @xpToLevel
#SHOW tempXpValue: @tempXpValue
#SHOW PercentThroughLevel: @PercentThroughLevel
Here's the output:
You have acquired 167433680 experience points so far this level.
You need 39724719 experience points to gain level 72.
xpIntoLevel: 167433680
xpToLevel: 39724719
tempXpValue: 207158399
PercentThroughLevel: 0
Is cMud unable to do math on numbers this large? I've tried them all Integers, floats, autotypes... it evaluates to .80, so i thought I should try
#VAR PercentThroughLevel ((@xpIntoLevel / @tempXpValue)*100), but that still evaluated to 0.
I tried
#VAR PercentThroughLevel ((@xpIntoLevel *100 ) / @tempXpValue), but that evaluated to -2
Is there a reliable bigDecimal type variable? |
|
|
 |
Zhiroc Adept
Joined: 04 Feb 2005 Posts: 246
|
Posted: Sat Aug 11, 2007 6:32 pm |
Do:
#VAR PercentThroughLevel (@xpIntoLevel * 1.0 / @tempXpValue)
to convert the calculation into floating point. |
|
|
 |
haiku Wanderer
Joined: 19 Nov 2004 Posts: 70
|
Posted: Sat Aug 11, 2007 6:35 pm |
thanks, that worked!
|
|
|
 |
haiku Wanderer
Joined: 19 Nov 2004 Posts: 70
|
Posted: Sat Aug 11, 2007 6:46 pm |
ok, next question... how do I truncate it so that I'm only seeing 2 places after the decimal point?
|
|
|
 |
haiku Wanderer
Joined: 19 Nov 2004 Posts: 70
|
Posted: Sat Aug 11, 2007 6:53 pm |
or better yet, how do i cast it back into an integer?
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat Aug 11, 2007 7:01 pm |
To truncate: %int
To round: %round |
|
|
 |
Vijilante SubAdmin

Joined: 18 Nov 2001 Posts: 5187
|
Posted: Sat Aug 11, 2007 7:52 pm |
Also there is the %format function.
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
 |
|
|