Re: now it's possible! printing floating point numbers at compile-time

ketmar ketmar at ketmar.no-ip.org
Sun Dec 30 13:26:33 UTC 2018


Basile B. wrote:

> On Sunday, 30 December 2018 at 12:19:19 UTC, ketmar wrote:
>> too bad that i didn't knew about Ryu back than.
>
> It's very recent, announce on proggit is < 1 year.
>
> It would be nice to have one to format in phobos. RYU or Grisu3 doesn't 
> matter much as long as the two issues that are
>
> - CTFE formatting of floats
> - formatting is identical on all platforms
actually, there is a 3rd issue, which is often overlooked: conversion from 
string to float. to get a perfect roundtrip, this one should be done right too.


> is solved. There's also the "real" problem. I'm pretty sure that 32 and 
> 64 bits floats are always handled. Someteimes 128 bits ones but not sure 
> for 80 bits...
80 bits can (usually) be extended to 128. you'll get some extra meaningless 
digits, of course, but it is better than nothing, i think.

actually, Ryu has all the math to derive 80-bit implementation. it will 
require 128-bit integers, though. (less than 128, but there is no sense in 
using smaller ints anyway).


More information about the Digitalmars-d-announce mailing list