News for hackers. Stuff that matters.
Re:Show HN: Shellmath: Floating-point arithmetic directly in... by clarity20 on Wednesday February 24, 2021 @10:24AM (#26250826)
Hello, all!

I'm proud to present shellmath, a floating-point calculator written entirely in bash.

Shellmath does not call out to any external programs -- calculators, text manipulators, or anything else -- and achieves execution speeds competitive with GNU awk and bc.

You can do floating-point math directly in the shell, and now you have a ready-made family of routines for doing so!

For skeptics ;-) I've included a demo that calculates 'e'. I've also posted a few words about the methodology, runtime efficiency, and a few bells and whistles on the README and in the project wiki.

I eagerly await your feedback!

Be good, and have a great day!

Re:Show HN: Shellmath: Floating-point arithmetic directly in... by JNRowe on Wednesday February 24, 2021 @02:34PM (#26254515)
This is awful¹, I love it!

Thumbing through the code made me wonder what the zsh(my normal shell) implementation feels like, and I think it is fair to say your code is easier to wrap your head around than the documentation for floats in zsh.

FWIW - and given that you've only shown Windows timings - on my Linux box hyperfine shows:

    Summary
      './faster_e_demo.sh 15' ran
        1.78 ± 0.16 times faster than './slower_e_demo.sh 15'
I expected the speeds to be closer because of the differences with subshells on Windows and Linux, but the distance still surprised me.

¹ https://en.m.wiktionary.org/wiki/contranym - choose one

Re:Show HN: Shellmath: Floating-point arithmetic directly in... by clarity20 on Thursday February 25, 2021 @09:13AM (#26262894)
Thank you, I tried to make the code as readable as I could. And yes, since the *nix model for (sub)processes is cleaner than Cygwin-on-Windows it's kind of surprising that that gap is what it is.
Re:Show HN: Shellmath: Floating-point arithmetic directly in... by pabs3 on Thursday February 25, 2021 @12:15AM (#26259948)
Who does the name in the description refer to?
Re:Show HN: Shellmath: Floating-point arithmetic directly in... by tzs on Thursday February 25, 2021 @01:25AM (#26260273)
Re:Show HN: Shellmath: Floating-point arithmetic directly in... by clarity20 on Thursday February 25, 2021 @09:02AM (#26262781)
;-)