ld_sprint

Undocumented in source. Be warned that the author may not have intended to support it.
version(CRuntime_Microsoft)
extern (C++) nothrow @nogc pure @trusted @safe @system
size_t
ld_sprint
(
char* str
,
int fmt
,)

Examples

///////////////////////////////////////////////////////////

1 import core.stdc.string;
2 import core.stdc.stdio;
3 
4 char[32] buffer;
5 ld_sprint(buffer.ptr, 'a', ld_pi);
6 assert(strcmp(buffer.ptr, "0x1.921fb54442d1846ap+1") == 0);
7 
8 ld_sprint(buffer.ptr, 'g', longdouble_soft(2.0));
9 assert(strcmp(buffer.ptr, "2.00000") == 0);
10 
11 ld_sprint(buffer.ptr, 'g', longdouble_soft(1234567.89));
12 assert(strcmp(buffer.ptr, "1.23457e+06") == 0);
13 
14 ld_sprint(buffer.ptr, 'g', ld_inf);
15 assert(strcmp(buffer.ptr, "inf") == 0);
16 
17 ld_sprint(buffer.ptr, 'g', ld_qnan);
18 assert(strcmp(buffer.ptr, "nan") == 0);
19 
20 longdouble_soft ldb = longdouble_soft(0.4);
21 long b = cast(long)ldb;
22 assert(b == 0);
23 
24 b = cast(long)longdouble_soft(0.9);
25 assert(b == 0);
26 
27 long x = 0x12345678abcdef78L;
28 longdouble_soft ldx = longdouble_soft(x);
29 assert(ldx > ld_zero);
30 long y = cast(long)ldx;
31 assert(x == y);
32 
33 x = -0x12345678abcdef78L;
34 ldx = longdouble_soft(x);
35 assert(ldx < ld_zero);
36 y = cast(long)ldx;
37 assert(x == y);
38 
39 ulong u = 0x12345678abcdef78L;
40 longdouble_soft ldu = longdouble_soft(u);
41 assert(ldu > ld_zero);
42 ulong v = cast(ulong)ldu;
43 assert(u == v);
44 
45 u = 0xf234567812345678UL;
46 ldu = longdouble_soft(u);
47 assert(ldu > ld_zero);
48 v = cast(ulong)ldu;
49 assert(u == v);
50 
51 u = 0xf2345678;
52 ldu = longdouble_soft(u);
53 ldu = ldu * ldu;
54 ldu = sqrt(ldu);
55 v = cast(ulong)ldu;
56 assert(u == v);
57 
58 u = 0x123456789A;
59 ldu = longdouble_soft(u);
60 ldu = ldu * longdouble_soft(1L << 23);
61 v = cast(ulong)ldu;
62 u = u * (1L << 23);
63 assert(u == v);

Meta