BSD style: see
license.txt
Nov 2005: Initial release
Jan 2010: added internal ecvt()
Kris
A set of functions for converting between string and floating-
point values.
Applying the D "import alias" mechanism to this module is highly
recommended, in order to limit namespace pollution:
1
2
3
| import Float = tango.text.convert.Float;
auto f = Float.parse ("3.14159");
|
- enum [private] ¶#
-
Constants
- NumType toFloat(T)(T[] src) ¶#
-
Convert a formatted string of digits to a floating-point
number. Throws an exception where the input text is not
parsable in its entirety.
- char[] toString(NumType d, uint decimals = Dec, int e = Exp) ¶#
-
Template wrapper to make life simpler. Returns a text version
of the provided value.
See format() for details
- wchar[] toString16(NumType d, uint decimals = Dec, int e = Exp) ¶#
-
Template wrapper to make life simpler. Returns a text version
of the provided value.
See format() for details
- dchar[] toString32(NumType d, uint decimals = Dec, int e = Exp) ¶#
-
Template wrapper to make life simpler. Returns a text version
of the provided value.
See format() for details
- T[] truncate(T)(T[] s) ¶#
-
Truncate trailing '0' and '.' from a string, such that 200.000
becomes 200, and 20.10 becomes 20.1
Returns a potentially shorter slice of what you give it.
- bool negative(NumType x) [private] ¶#
-
Extract a sign-bit
- T[] format(T, D = NumType, U = int)(T[] dst, D x, U decimals = Dec, U e = Exp, bool pad = Pad) ¶#
-
Convert a floating-point number to a string.
The e parameter controls the number of exponent places emitted,
and can thus control where the output switches to the scientific
notation. For example, setting e=2 for 0.01 or 10.0 would result
in normal output. Whereas setting e=1 would result in both those
values being rendered in scientific notation instead. Setting e
to 0 forces that notation on for everything. Parameter pad will
append trailing '0' decimals when set ~ otherwise trailing '0's
will be elided
- NumType parse(T)(T[] src, uint* ate = null) ¶#
-
Convert a formatted string of digits to a floating-point number.
Good for general use, but use David Gay's dtoa package if serious
rounding adjustments should be applied.
- NumType pow10(uint exp) [private] ¶#
-
Internal function to convert an exponent specifier to a floating
point value.