$ filename "quads.exe"
'use rtl32
'use rtl64
uses console
quad i=1e16
printl "1e16 = " i
i=10000000000000000
printl "as number = " i
i=pow(10,16)
printl "pow(10,16) = " i
printl
i=1e17
printl "le17 = " i
i=100000000000000000
printl "as number = " i
i=pow(10,17)
printl "pow(10,17) = " i
printl
i=1e18
printl "1e18 = " i
i=1000000000000000000
printl "as number = " i
i=pow(10,18)
printl "pow(10,18) = " i
printl
printl "Enter ... " : waitkey
'03:43 11/08/2018
'msvcrt val/str/format$ equivalent
'http://www.cplusplus.com/reference/cstdio/printf/
'nb: msvcrt downgrades extended precision to double.
uses msvcrt 'or corewin
char odata[64]
sprintf(odata,"%g", double 1/3) '0.333333
print odata
sprintf(odata,"%lli", quad 9/5) '2
print odata
#include <stdio.h>
#include <math.h>
int main () {
int c;
printf("2^31-1 = %lf\n", pow(2, 31)-1);
printf("2^32-1 = %lf\n", pow(2, 32)-1);
printf("2^63-1 = %lf\n", pow(2, 63)-1);
printf("2^64-1 = %lf\n", pow(2, 64)-1);
printf("Enter: ... ");
c=getchar();
return(0);
}
printf("2^63-1 = %Lf\n", powl(2, 63)-1L);
printf("2^64-1 = %Lf\n", powl(2, 64)-1L);
and see what it's output will be$filename "t.exe"
uses rtl64
uses corewin
char od[64]
double d=(2^63)-1
sprintf od,"%g", double (2^63)-1 : print od
sprintf od,"%g", double d : print od
print ( (2^63)-1 )
But it seems that for MS Windows msvcrt.dll is delivered with every version since Win95.
$filename "t.exe"
uses rtl64
uses corewin
function cformat(char*f, ...) as string
=======================================
'restricted to one value only
indexbase 1
char od[64]
#ifdef mode64bit
sprintf od,f,param[2]
#else
sprintf od,f,param[2],param[3]
#endif
return od
end function
print cformat( "%g" , (2^63)-1 )
Varargsand
11/03/2016
2 minutes to read
Contributors
Colin Robertson Mike Jones Mike B Gordon Hogenson Saisang Cai
If parameters are passed via varargs (for example, ellipsis arguments), then essentially the normal parameter passing applies including spilling the fifth and subsequent arguments. It is again the callee's responsibility to dump arguments that have their address taken. For floating-point values only, both the integer and the floating-point register will contain the float value in case the callee expects the value in the integer registers.
Parameter Passingfrom that I gather that floats are passed to both xmm0 .. xmm3 and RCX, RDX, R8, and R9, I have not tested if this is actually true.
11/03/2016
2 minutes to read
Contributors
Colin Robertson Mike Jones Mike B Gordon Hogenson Saisang Cai
The first four integer arguments are passed in registers. Integer values are passed (in order left to right) in RCX, RDX, R8, and R9. Arguments five and higher are passed on the stack. All arguments are right-justified in registers. This is done so the callee can ignore the upper bits of the register if need be and can access only the portion of the register necessary.
Floating-point and double-precision arguments are passed in XMM0 - XMM3 (up to 4) with the integer slot (RCX, RDX, R8, and R9) that would normally be used for that cardinal slot being ignored (see example) and vice versa.
sub rsp,32 'create spill zone for 4 registers on the stack
mov eax,a
movss xmm1,b
mov r8d,c
movss xmm3,d
call foo
add rsp,32 'restore stack pointer position
sub rsp,32 'create spill zone for 4 registers on the stack
movsd xmm0,a
mov rdi,b
movsd xmm2,c
mov r9,d
call bah
add rsp,32 'restore stack pointer position
$ filename "Ranges4.exe"
'use rtl32
use rtl64
uses corewin
uses console
function cformat(char*f, ...) as string
=======================================
...
double d, quad q
d=(2^64)-1 : printl "2^64-1 = " cformat( "%f" , d ) '18446744073709552000
q=-0x2 : printl "2^64-2 = " cformat( "%I64u" , q ) '18446744073709551614
q=-0x1 : printl "2^64-1 = " cformat( "%I64u" , q ) '18446744073709551615
printl "Enter: ... " : waitkey