how to display a percentage from a float number ?

BlitzMax Forums/BlitzMax Beginners Area/how to display a percentage from a float number ?

hub(Posted 2006) [#1]
Hi !
how to display a percentage from a float number ? Imagine :

Percentage = 12.58585 ' a float number in my program

now i want display :

your percentage : 12.58%
your score 12,58 x 1000 = 12580

other case :

your percentage : 100%
your score 100% x 1000 = 100000

another :

your percentage : 1.58%
your score 1.58 x 1000 = 1580

Thanks for your help !


deps(Posted 2006) [#2]
Do you mean that you only want 2 decimals?
Maybe something like this:
local str:string = string( percentage )
local dd:int = instr( str, "." )
str = str[..(dd+2)]
drawtext( "Your percentage : "+str+"%", 100,100 )

(untested)


hub(Posted 2006) [#3]
Thanks peter !


ImaginaryHuman(Posted 2006) [#4]
or...

drawtext("Your percentage : "+String(Int(percentage))+"."+(Right$(String(Int(percentage*100)),2))+"%",100,100)

Something like that.