tango.text.convert.Float

Members

Functions

format
T[] format(T[] dst, NumType x, int decimals, int e, bool pad)

Convert a floating-point number to a string.

format
T[] format(T[] dst, D x, U decimals, int e, bool pad)

Convert a float to a string. This produces pretty good results for the most part, though one should use David Gay's dtoa package for best accuracy.

format
T[] format(T[] dst, NumType x, uint decimals, int e, bool pad)
Undocumented in source. Be warned that the author may not have intended to support it.
main
void main()
Undocumented in source. Be warned that the author may not have intended to support it.
parse
NumType parse(const(char[]) src, size_t* ate)

Convert a formatted string of digits to a floating- point number.

parse
NumType parse(const(wchar[]) src, size_t* ate)

Convert a formatted string of digits to a floating- point number.

parse
NumType parse(const(dchar[]) src, size_t* ate)

Convert a formatted string of digits to a floating- point number.

parse
NumType parse(const(T[]) src, size_t* ate)

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.

toFloat
NumType toFloat(const(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.

toString
char[] toString(NumType d, uint decimals, int e)

Template wrapper to make life simpler. Returns a text version of the provided value.

toString16
wchar[] toString16(NumType d, uint decimals, int e)

Template wrapper to make life simpler. Returns a text version of the provided value.

toString32
dchar[] toString32(NumType d, uint decimals, int e)

Template wrapper to make life simpler. Returns a text version of the provided value.

truncate
T[] truncate(T[] s)

Truncate trailing '0' and '.' from a string, such that 200.000 becomes 200, and 20.10 becomes 20.1

Meta

License

BSD style: $(LICENSE)

Version

Nov 2005: Initial release Jan 2010: added internal ecvt()

Authors

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:

import Float = tango.text.convert.Float;

auto f = Float.parse ("3.14159");