formatting a float or double in a string with all significant digits kept

dan dan.hitt at gmail.com
Fri Oct 11 01:52:22 UTC 2019


On Thursday, 10 October 2019 at 22:44:05 UTC, H. S. Teoh wrote:
> On Thu, Oct 10, 2019 at 09:13:05PM +0000, Jon Degenhardt via 
> Digitalmars-d-learn wrote:
>> On Thursday, 10 October 2019 at 17:12:25 UTC, dan wrote:
>> > Thanks also berni44 for the information about the dig 
>> > attribute, Jon
>> > for the neat packaging into one line using the attribute on 
>> > the
>> > type.
>> > Unfortunately, the version of gdc that comes with the 
>> > version of
>> > debian that i am using does not have the dig attribute yet, 
>> > but
>> > perhaps i can upgrade, and eventually i think gdc will have 
>> > it.
>
> What's the output of dmd --version?  I find it extremely odd 
> that .dig isn't supported.  AFAIK, it's been there since the 
> early days of D. Certainly, it has been there since I started 
> using D, which was before dmd was ever available in Debian.
>
> What's the compiler output of:
>
> 	pragma(msg, float.dig);
>
> ?
>
>
> T

Thanks HS!

I sure thought i got a compile time error when i used .dig, but i 
tried
it again, and it works.

I tried the pragma, and it printed out 6, and i tried PI.dig and 
double.dig
and they're all working now.

Just for reference, i'm using what i think is the standard gdc on 
debian 9,
not dmd, and the version is 2068L.

Thanks again for your help in encouraging me to try harder, and 
thanks again
everybody else for all the help.

dan








More information about the Digitalmars-d-learn mailing list