Replacement for snprintf

Jon Degenhardt jond at noreply.com
Wed Oct 30 17:50:03 UTC 2019


On Wednesday, 30 October 2019 at 16:04:10 UTC, berni44 wrote:
> On Wednesday, 30 October 2019 at 15:48:44 UTC, Ali Çehreli 
> wrote:
>> The tie-breaker is to always round towards the even digit. So 
>> it should always produce 1.12, 1.14, etc.
>
> As far as I know that's for avoiding error propagation, when 
> intermediate results need to be rounded. When I'm not 
> completely mistaken, Donald Knuth prooved that rounding toward 
> even avoids errors that might building up using several such 
> steps.
>
> But here there is little chance, that the result will be used 
> for new calculations. It's most often used for printing a 
> result that humans have to read. This is different.

It's reasonably common to have numeric values written out in text 
format and read back in and used in subsequent computations. Not 
always a great idea, especially when done without much 
consideration for round-off errors. But it's not uncommon.

--Jon


More information about the Digitalmars-d mailing list