1 assertEq( floatToStrSci( 0 ), "0.000000e+00" ); 2 assertEq( floatToStrSci( 3.1415 ), "3.141500e+00" ); 3 assertEq( floatToStrSci( 314.15 ), "3.141500e+02" ); 4 assertEq( floatToStrSci( 0.0314 ), "3.139999e-02" ); 5 assertEq( floatToStrSci( 3.14159e-8 ), "3.141590e-08" ); 6 assertEq( floatToStrSci( 3.1415e11 ), "3.141500e+11" ); 7 assertEq( floatToStrSci( 3.1415e11, 10, 3, PlusSig.PLUS ), "+3.141e+11" ); 8 9 import std.string : format; 10 11 foreach( i; 0 .. 1000 ) 12 { 13 auto v = .001 * i; 14 assertEqApprox( to!double( floatToStrSci(v) ), v, .001, 15 format( "%%s != %%s with i: %s", i ) ); 16 } 17 18 assertEq( floatToStrSci( 3.141592, 12, 5, PlusSig.SPACE ), " 3.14159e+00" );