mailing list of musl libc
 help / color / mirror / code / Atom feed
From: newbie nullzwei <newbie-02@gmx.de>
To: musl@lists.openwall.com
Subject: Aw: Re: [musl] DTOA: question about rendering / code pointer
Date: Wed, 17 May 2023 09:41:03 +0200	[thread overview]
Message-ID: <trinity-ed37f7ac-283e-4b00-a39f-fcae8d83ee80-1684309263348@3c-app-gmx-bap41> (raw)
In-Reply-To: <20230516193627.GM4163@brightrain.aerifal.cx>


@Rich: thank you for fast comment,

> musl always, and very intentionally, performs correct rounding
according to the current rounding direction for all conversions
to/from decimal.

yes, there is a tension if and where 'correctly rounded' is still or
no longer useful. From a decimal point of view, and thus that of
many users, it loses usefulness at the point where it prefers the
inaccuracy of the binary representation over the decimal 'equivalent'.

> Getting the shortest decimal string that round-trips
is a somewhat different problem, and not one libc has any API for.

Accordingly, it is a weakness for decimal <-> binary compatibility
if libraries, API's ... do not take 'SRT' into account. Similar to
the even IEEE rounding mode 'ties to evil' ( where 'ties away from
zero' is often mentioned but not implemented except in round()
- and there insufficient ). This is also a huge buzzkill to get
decimal acceptable results with binary placeholder math.

> But if what you want is shortest string which round-trips, I think
there are faster approaches than what musl does; ensuring exactness
like wedo is more work.

I have also considered and researched alternatives, but it would
be a bigger change, and brings new, e.g. licensing difficulties.
The current best SRT solutions are not simpler, see ryu, Schubfach,
SwiftDtoa ... they are really clobbering to be accurate and fast,
I was positively surprised that musl added with trial and error
afterburner can keep up well.
If there is a version of your code with more comments, or if you can
explain to me where the last digit is constructed / rounded and which
variables mean what there, I would like to try to patch it. ( I know,
professionals read such like a shopping list, I unfortunately do not ).

@alice: thank you for fast comment,

> dragonbox/schubfach is probably exactly what you're looking for,
for which a (c++) reference implementation is at
https://github.com/jk-jeon/dragonbox

thanks for the hint, had already looked there, C++ is not an option
for gnumeric, and I didn't get all alternatives to work and test,
- ryu I have mostly ready, is difficult / somewhat slow for long
doubles, I couldn't yet convince the maintainer,
- SwiftDtoa - popped very well working out of the box, but there are
questions that Swits Apache License isn't compatible with GNU GPL2
which gnumeric wants to keep.

> afaik libreoffice now uses this for the same usecase(?).

I am surprised and happy that LibreOffice uses reasonable solutions,
but I am afraid that all profit will be lost in their unrestrained
prettyfying.


  parent reply	other threads:[~2023-05-17 12:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-16 18:49 newbie nullzwei
2023-05-16 19:36 ` Rich Felker
2023-05-16 19:46   ` alice
2023-05-17  7:41   ` newbie nullzwei [this message]
2023-05-17 13:09     ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=trinity-ed37f7ac-283e-4b00-a39f-fcae8d83ee80-1684309263348@3c-app-gmx-bap41 \
    --to=newbie-02@gmx.de \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).