Changing String Output Length of Floating Point Numbers
Casting a float to string outputs a string with six significant decimal digits by default. Casting a double value to a string outputs with 15 significant decimal digits by default.
Casting a Floating Point Number to a String
You can reduce the number of significant decimal digits by specifying an integer value less than or equal to the default as shown below.
Cast float to string |
---|
Default cast of float to string
|
Cast of float to string with three significant decimal digits (less than 6)
|
Attempt to cast of double to string with 100 signficiant decimal digits (greater than 6).
|
Cast double to string |
---|
Default cast of double to string
|
Cast of double to string with ten significant decimal digits (less than 15)
|
Attempt to cast of double to string with 100 signficiant decimal digits (greater than 15).
|
The number of significant decimal digits in the output is limited to a maximum of six for float data types and 15 for double data types.Â