Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > comp.unix.shell > #26581
| From | Kaz Kylheku <643-408-1753@kylheku.com> |
|---|---|
| Newsgroups | comp.unix.shell |
| Subject | Re: handy shell function/alias that wraps bc |
| Date | 2025-11-04 04:40 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <20251103203548.929@kylheku.com> (permalink) |
| References | (3 earlier) <10eaesd$2u47l$1@dont-email.me> <10eak74$vgfp$1@news.xmission.com> <10eakvt$30ji5$1@dont-email.me> <slrn10gie3u.2djo.naddy@lorvorc.mips.inka.de> <10ebvo2$3d90e$1@dont-email.me> |
On 2025-11-04, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote: > On 04.11.2025 00:19, Christian Weisgerber wrote: >> On 2025-11-03, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote: >> >>> $ zsh -c 'echo $(( 1.0+2.3 ))' >>> 3.2999999999999998 >>> >>> $ ksh -c 'echo $(( 1.0+2.3 ))' >>> 3.3 >>> >>> Zsh is not really confidence-inspiring here. - Hmm.. >> >> I think 0.3 cannot be represented in binary floating point format, >> so you are getting an approximation. Zsh and ksh appear to apply >> different rounding on output. It's probably just the difference >> between %.17g and %g or such. > > Yes, sure. - It's just that my "simple" pocket-calculator that > I bought around 1980 does not show such obvious rounding errors > (i.e. with numbers it can not exactly represent). Calculators use the same base for calculating that they do for displaying and input. That makes all the difference. You literally cannot input anything into your calculator that it cannot represent. It supports an exact representation of 0.3, or anything else you can punch in. You can calculate something it cannot represent, like dividing 1 by 3. But it does that in decimal and can truncate and round as you would using pencil-and-paper calculations. If it agrees with pencil-and-paper model decimal calculations, you will find it flawless. :) -- TXR Programming Language: http://nongnu.org/txr Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal Mastodon: @Kazinator@mstdn.ca
Back to comp.unix.shell | Previous | Next — Previous in thread | Next in thread | Find similar
handy shell function/alias that wraps bc Michael Sanders <porkchop@invalid.foo> - 2025-10-31 06:32 +0000
Re: handy shell function/alias that wraps bc Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-10-31 06:38 +0000
Re: handy shell function/alias that wraps bc gazelle@shell.xmission.com (Kenny McCormack) - 2025-10-31 10:16 +0000
Re: handy shell function/alias that wraps bc Michael Sanders <porkchop@invalid.foo> - 2025-10-31 15:49 +0000
Re: handy shell function/alias that wraps bc Geoff Clare <geoff@clare.See-My-Signature.invalid> - 2025-10-31 13:16 +0000
Re: handy shell function/alias that wraps bc Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-10-31 23:29 +0000
Re: handy shell function/alias that wraps bc Michael Sanders <porkchop@invalid.foo> - 2025-10-31 15:31 +0000
Re: handy shell function/alias that wraps bc Jim <zsd+ng@jdvb.ca> - 2025-11-07 10:09 -0400
Re: handy shell function/alias that wraps bc Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-11-08 00:00 +0000
Re: handy shell function/alias that wraps bc Christian Weisgerber <naddy@mips.inka.de> - 2025-11-08 16:51 +0000
Re: handy shell function/alias that wraps bc Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-11-08 21:55 +0000
Re: handy shell function/alias that wraps bc Jim Diamond <zsd@jdvb.ca> - 2025-11-19 20:37 -0400
Re: handy shell function/alias that wraps bc Brian Patrie <bpatrie@bellsouth.spamisicky.net> - 2025-11-23 14:40 -0600
Re: handy shell function/alias that wraps bc Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-11-23 20:58 +0000
Re: handy shell function/alias that wraps bc Jim Diamond <zsd@jdvb.ca> - 2025-11-24 21:12 -0400
Re: handy shell function/alias that wraps bc Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-10-31 10:38 +0100
Re: handy shell function/alias that wraps bc gazelle@shell.xmission.com (Kenny McCormack) - 2025-10-31 12:39 +0000
Re: handy shell function/alias that wraps bc Kaz Kylheku <643-408-1753@kylheku.com> - 2025-10-31 17:03 +0000
Re: handy shell function/alias that wraps bc Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-10-31 18:14 +0100
Re: handy shell function/alias that wraps bc Richard Harnden <richard.nospam@gmail.invalid> - 2025-11-03 14:03 +0000
Re: handy shell function/alias that wraps bc Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-11-03 15:10 +0100
Re: handy shell function/alias that wraps bc Richard Harnden <richard.nospam@gmail.invalid> - 2025-11-03 14:40 +0000
Re: handy shell function/alias that wraps bc gazelle@shell.xmission.com (Kenny McCormack) - 2025-11-03 16:11 +0000
Re: handy shell function/alias that wraps bc Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-11-03 17:24 +0100
Re: handy shell function/alias that wraps bc gazelle@shell.xmission.com (Kenny McCormack) - 2025-11-03 17:33 +0000
Re: handy shell function/alias that wraps bc Christian Weisgerber <naddy@mips.inka.de> - 2025-11-03 23:19 +0000
Re: handy shell function/alias that wraps bc Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-11-04 05:34 +0100
Re: handy shell function/alias that wraps bc Kaz Kylheku <643-408-1753@kylheku.com> - 2025-11-04 04:40 +0000
Re: handy shell function/alias that wraps bc Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-11-04 05:57 +0100
Re: handy shell function/alias that wraps bc Kaz Kylheku <643-408-1753@kylheku.com> - 2025-11-04 00:35 +0000
Re: handy shell function/alias that wraps bc Kaz Kylheku <643-408-1753@kylheku.com> - 2025-11-04 01:04 +0000
Re: handy shell function/alias that wraps bc Christian Weisgerber <naddy@mips.inka.de> - 2025-11-03 15:56 +0000
Re: handy shell function/alias that wraps bc Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-11-03 20:06 +0000
Re: handy shell function/alias that wraps bc Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-11-03 21:25 +0100
Re: handy shell function/alias that wraps bc Kaz Kylheku <643-408-1753@kylheku.com> - 2025-11-03 21:11 +0000
Re: handy shell function/alias that wraps bc Michael Sanders <porkchop@invalid.foo> - 2025-10-31 15:53 +0000
Re: handy shell function/alias that wraps bc Christian Weisgerber <naddy@mips.inka.de> - 2025-10-31 14:56 +0000
Re: handy shell function/alias that wraps bc Michael Sanders <porkchop@invalid.foo> - 2025-10-31 15:54 +0000
Re: handy shell function/alias that wraps bc Nuno Silva <nunojsilva@invalid.invalid> - 2025-11-01 10:43 +0000
Re: handy shell function/alias that wraps bc Michael Sanders <porkchop@invalid.foo> - 2025-11-01 12:29 +0000
Re: handy shell function/alias that wraps bc Michael Sanders <porkchop@invalid.foo> - 2025-10-31 17:51 +0000
Re: handy shell function/alias that wraps bc ram@zedat.fu-berlin.de (Stefan Ram) - 2025-10-31 18:21 +0000
Re: handy shell function/alias that wraps bc Michael Sanders <porkchop@invalid.foo> - 2025-10-31 19:15 +0000
Re: handy shell function/alias that wraps bc Ed Morton <mortonspam@gmail.com> - 2025-11-01 11:47 -0500
Re: handy shell function/alias that wraps bc Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-11-01 20:21 +0000
Other languages and people's personal issues (Was: handy shell function/alias that wraps bc) gazelle@shell.xmission.com (Kenny McCormack) - 2025-11-01 21:27 +0000
Re: handy shell function/alias that wraps bc Ed Morton <mortonspam@gmail.com> - 2025-11-02 16:58 -0600
Re: handy shell function/alias that wraps bc Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-11-03 01:53 +0000
Re: handy shell function/alias that wraps bc gazelle@shell.xmission.com (Kenny McCormack) - 2025-11-03 02:39 +0000
Re: handy shell function/alias that wraps bc Ed Morton <mortonspam@gmail.com> - 2025-11-04 16:49 -0600
Re: handy shell function/alias that wraps bc Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-11-05 00:06 +0000
Re: handy shell function/alias that wraps bc Kaz Kylheku <643-408-1753@kylheku.com> - 2025-11-04 23:06 +0000
csiph-web