www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Floating point precision with writeln

reply Maynard Kaiser <m.kaiser oakisland.ca> writes:
Top o' the day, folks!

I'm working with floats, doubles to be precise. Whenever I write 
them to the console, the maximum precision I get is 5 digits 
after after the separator.
If I wanted to have 8 or 9 digits after the separator, what would 
I have to do?
Jun 01
parent reply Serg Gini <kornburn yandex.ru> writes:
On Saturday, 1 June 2024 at 10:44:50 UTC, Maynard Kaiser wrote:
 Top o' the day, folks!

 I'm working with floats, doubles to be precise. Whenever I 
 write them to the console, the maximum precision I get is 5 
 digits after after the separator.
 If I wanted to have 8 or 9 digits after the separator, what 
 would I have to do?
```d import std; void main() { writefln("%1.14f", std.math.PI); } ```
Jun 01
parent Maynard Kaiser <m.kaiser oakisland.ca> writes:
Thanks a lot! That helped.

On Saturday, 1 June 2024 at 10:49:10 UTC, Serg Gini wrote:
 On Saturday, 1 June 2024 at 10:44:50 UTC, Maynard Kaiser wrote:
 Top o' the day, folks!

 I'm working with floats, doubles to be precise. Whenever I 
 write them to the console, the maximum precision I get is 5 
 digits after after the separator.
 If I wanted to have 8 or 9 digits after the separator, what 
 would I have to do?
```d import std; void main() { writefln("%1.14f", std.math.PI); } ```
Jun 01