insect icon indicating copy to clipboard operation
insect copied to clipboard

Adaptive number of significant digits

Open sharkdp opened this issue 8 years ago • 7 comments

Adaptively increase the number of significant digits if the user input seems to require it:

> 3e6 + 0.1
3000000

Also, the different handling of integers and floating point numbers seems strange right now:

> 3e7 + 1
30000001
> 3e7 + 1.1
30000000

sharkdp avatar Mar 23 '17 19:03 sharkdp

Also, 0.1428571*7=1 Doesn't seem like a high precision calculator

tianshuo avatar Jun 26 '17 07:06 tianshuo

And also having the possibility to change the number of significant digits during a session could be a very useful feature (it is for me...)!

lampo808 avatar Nov 24 '17 15:11 lampo808

@sharkdp Stupid question: Why shouldn't Insect output all digits. Then the user can decide how many digits he wants to use ^^

ad-si avatar Jul 12 '18 07:07 ad-si

Also: I guess many people would like to use insect as a replacement for calc, so maybe insect should output similar solutions. E.g. calc easily handles things like calc '3e1000 + 0.1'

ad-si avatar Jul 12 '18 07:07 ad-si

I agree the current behaviour is very confusing. There's even a difference between big and small integers:

> 111111111111111111

  111111111111111111

   = 111111111111111111
> 1111111111111111111

  1111111111111111111

   = 1111110000000000000

I think a more usable default would be to display six (or even eight) digits after the dot. It can be still made configurable later on.

Otherwise at least use scientific notation when showing numbers bigger than 1e6 (now it does from 1e20 on, which seems a reasonable default).

@ad-si note that calc is an arbitrary precision calculator, while insect is just high precision.

pierstitus avatar Nov 02 '20 00:11 pierstitus

I agree the current behaviour is very confusing

Yes. This ticket describes my personal top-prio issue with Insect.

I think a more usable default would be to display six (or even eight) digits after the dot. It can be still made configurable later on.

We could try this. I don't really like the fact that we would display far too many digits for most computations though.

sharkdp avatar Nov 02 '20 19:11 sharkdp

I just want to confirm how important it is for some application to display >6 digits. Is there a way around it for now? I want to do 123456789/33 but need at least 15 significant digits.

NicoLugil avatar Mar 30 '22 07:03 NicoLugil

@sharkdp I think this could be nice to implement in v5.9.0, but the major initial hurdle would be how to add it cleanly to purescript-decimals's API. Do you have any ideas how we could do that?

triallax avatar Feb 11 '23 10:02 triallax

Do you have any ideas how we could do that?

I have not thought about it in detail, but I'm quite sure it's a highly nontrivial thing to do.

sharkdp avatar Feb 11 '23 19:02 sharkdp

@sharkdp alright then, let's leave it for later (or never?) then.

triallax avatar Feb 11 '23 22:02 triallax

Follow-up ticket for Numbat: https://github.com/sharkdp/numbat/issues/179

sharkdp avatar Sep 26 '23 19:09 sharkdp