systemstring(127)fn rtos(real r,integer n,m)
  constreal pmax = 2147483647.0
  real y,z
  integer i=0,l,count=0,sign
  string(127) result = ""
  !
  sign = ' '
  sign = '-' if r < 0
  y = |r|+0.5/10.0¬{^}m;  !modulus, rounded
  if y > pmax start
    count = count+1 and y = y/10.0 until y < 10.0
  finish
  z = 1.0
  cycle
    i = i+1;  z = z*10.0
  repeat until z > y
  result = result." " for l = 1,1,n-i;   !l not used before here
  result = result.tostring(sign) unless sign = ' ' and n <= 0
  cycle
    z = z/10.0
    l = int pt(y/z)
    y = y-l*z
    result = result.tostring(l+'0')
    i = i-1
    exit if i+m <= 0
    result = result."." if i = 0
  repeat
  result = result."@".itos(count,0) if count # 0
  result = result
end;   !rtos

endoffile