how to display a percentage from a float number ?

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

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 !

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)

Thanks peter !

or...

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

Something like that.