|
MaaQ Newbie
Joined: 03 Apr 2005 Posts: 3
|
Posted: Sun Apr 03, 2005 9:22 am
problems with decimal numbers |
im trying to monitor my stam use per round
here is an example of two rounds
ST[31.95%]
ST[30.52%]
here is my trigger
ST~[(%d)~.(%d)~%~]
the problem i am having is the decimal number, im not sure how to put a decimal value number into a variable then find the difference from the previous value. If anyone has any ideas on this id be thankful. |
|
|
|
nexela Wizard
Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
Posted: Sun Apr 03, 2005 9:44 am |
Just combine them
ST~[(%d)~.(%d)~%~]
stvar=%1.%2 |
|
|
|
MaaQ Newbie
Joined: 03 Apr 2005 Posts: 3
|
Posted: Sun Apr 03, 2005 10:51 am Thanks |
Thanks, that seems so simple im sorry to trouble you.
I am having a small problem though.
Why does my stamdiff variable go out so many decimal places
#VAR stam %5.%6
#MATH stamdiff (@stamp - @stam)
#VAR stam
#VAR stamp
#VAR stamdiff
#VAR stamp %5.%6
Variable: stam 71.14
Variable: stamp 71.95
Variable: stamdiff 0.80999755859375 |
|
|
|
Vodoc Apprentice
Joined: 11 Apr 2003 Posts: 119 Location: Sweden
|
Posted: Sun Apr 03, 2005 12:49 pm |
Use
Code: |
%left(@stamdiff, 4) |
to format the outcome to in this case "0.80". If you want it to round off properly will you have to make a function that checks the fifth letter and act on it.
Edit: Oh, and to answer your question of "Why?". The computer sees it as a "double" (data type) and calculates the answer, doubles ain't very precise though and thus the odd answer. |
|
|
|
MaaQ Newbie
Joined: 03 Apr 2005 Posts: 3
|
Posted: Sun Apr 03, 2005 3:29 pm Thanks for the help |
thanks alot
|
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Mon Apr 04, 2005 3:01 am |
There's a built-in function that normalizes a decimal number. You might wish to look into using that instead of %left().
|
|
_________________ EDIT: I didn't like my old signature |
|
|
|
|
|