Confused about something in the D book relating to precision

thebluepandabear therealbluepandabear at protonmail.com
Mon Dec 5 02:57:19 UTC 2022


Hello guys,

(Noob question.)

I would appreciate some help.

I am reading Ali's book on D language, and I am up to page 127 -- 
talking about format specifiers.

He says the following about the '%e' (exponent) specifier:

"e: A floating point argument is printed according to the 
following rules.
  - a single digit before the decimal mark
  - a decimal mark if precision is nonzero"

I am not understanding why Ali said there is a decimal mark if 
precision is nonzero?

How can a number have zero precision? I thought all numbers have 
a precision of greater than 0. I am confused what this means :/

Then he says:

"the required digits after the decimal mark, the number of which 
is determined
by precision (default precision is 6)"

Well double has a precision of 15, and when I print the following 
there aren't 15 digits after the decimal mark:

```D
	double value = 123.456789;
	writeln("precision: ", double.dig);
	writefln("with e: %e", value);
```

Output:

```
precision: 15
with e: 1.234568e+02
```

I feel like this section was explained poorly and it's confusing.




Help would be appreciated.


More information about the Digitalmars-d-learn mailing list