Posted: Wed Feb 18, 2004 5:53 pm Post subject: real number to string converison
I'm making a menu and want to add the total of a calculation in another font besides the default one. When i use the Draw.Font command it will only accept strings. Is there a way to comehow convert the total, which is a real number, to a string so the font.draw will accpet it?
Sponsor Sponsor
Tony
Posted: Wed Feb 18, 2004 6:11 pm Post subject: (No subject)
Quote:
realstr ( r : real, width : int ) : string
thought the width part doesn't really seem to do anything You might have to use index() to locate decimal point and round the string yourself if you have to
Posted: Thu Feb 19, 2004 6:47 pm Post subject: (No subject)
code:
var r:real:=3.14159265859
function real2str (r:real, d:int) :string
var s:string
var nd:int:=d
if(nd >= 9) then
nd:=8
end if
var temp:real:= (r - floor(r)) * 10**(nd)
s:=intstr(floor(r)) + "." + intstr(round(temp))
result s
end real2str
put real2str(r,9)
% real2str(real number, number of digits after decimal)