'03:43 11/08/2018
'msvcrt val/str/format$ equivalent
'http://www.cplusplus.com/reference/cstdio/scanf/
'http://www.cplusplus.com/reference/cstdio/printf/
'% filename "t.exe"
'use rtl64
use windows/msvcrt
'
extended e
quad q
double d
float f
int dt
char idata[64]
char odata[64]
'
idata="0xA0DD7CBFF9FED839"
sscanf(idata,"%llx",@q) 'hexadecimal input to 64bit
sprintf(odata,"%llu",q)'64bit unsigned decimal output
'print idata chr(13,10) odata

idata="12348"
'nb: msvcrt downgrades extended precision to double.
if instr(idata,".") then
  sscanf(idata,"%lg",@d)
  dt=1
  e=d
else
  sscanf(idata,"%lli",@q)
  dt=0
  e=q
end if
fld eword e

if dt then
  fstp qword d
  sprintf(odata,"%e", double d)
else
  fistp qword q
  sprintf(odata,"%ll", quad q)
end if

print idata chr(13,10) odata


