
-----------------------------------
Da_Big_Ticket
Mon Oct 31, 2005 2:32 pm

Restricting variables to 2 decimal places
-----------------------------------
i know that if you want to restrict the number of decimal spaces on an output it would be :

variable : 0 : 2

However, I am font drawing variables in my program, and these variables have values assigned to them

For example balanceowing := opening + interest
Font.Draw realstr (balanceowing,5,), 120 , 230, font1, white)

How would you restrict this output to 2 decimals? Sinse it does have a values assigned to it via other variables and it is font drawn


Also if anyone knows how to get rid of the 7.14321e6 exponent junk would you be able to give me the solution? Thanks

-----------------------------------
MysticVegeta
Mon Oct 31, 2005 2:40 pm


-----------------------------------
I havent tested this this might work
var v2 := realstr(variable, 2)
v2 := v2(1..index(v2,".")+2)

-----------------------------------
[Gandalf]
Mon Oct 31, 2005 4:53 pm


-----------------------------------
I am fairly sure you simply mean to round a value to 2 decimal places instead of just cutting it off?

var pi : real := 3.14159
put pi
put round(pi * 100) / 100

-----------------------------------
MysticVegeta
Mon Oct 31, 2005 6:52 pm


-----------------------------------
var pi : real := 3.14159 
put frealstr (pi, 2, 2)

even more wyas of doing that!@

-----------------------------------
Da_Big_Ticket
Thu Nov 03, 2005 8:54 am


-----------------------------------
Thanks guys. I got it to work. What a relief
