*X-seq*: zsh-users 26598*From*: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>*To*: Ray Andrews <rayandrews@xxxxxxxxxxx>*Cc*: Zsh Users <zsh-users@xxxxxxx>*Subject*: Re: forcing float arithmetic.*Date*: Wed, 24 Mar 2021 19:37:35 -0700*Archived-at*: <https://zsh.org/users/26598>*Archived-at*: <http://www.zsh.org/sympa/arcsearch_id/zsh-users/2021-03/CAH%2Bw%3D7b7KsHEAm0vf3VNQiG6X4zOqr6QXcjBy7iSjy70Yq10VQ%40mail.gmail.com>*In-reply-to*: <0421525d-8304-6142-04bd-4f564ca043c0@eastlink.ca>*List-id*: <zsh-users.zsh.org>*References*: <f09863a2-0af9-dbff-08b9-6f595cd7e164@eastlink.ca> <CAH+w=7YJSqb+twS1X60LoJgVD95hAnJK3AAL6cA9tcafH2gqUg@mail.gmail.com> <aa6c84af-5a8c-e52a-ccb3-6a666ca2553c@eastlink.ca> <CAN=4vMq_i_FDqLbnVtZdbPEb3M58qoDdFzvf8mpQJQomtZLjHQ@mail.gmail.com> <CAH+w=7bOsdz17cfXTbNbwYXTJW_M9r67BnqVbNqkATZcU31=eQ@mail.gmail.com> <22260ea8-adec-6e16-9250-c2c2ab31fcba@eastlink.ca> <20210325013641.GE18178@tarpaulin.shahaf.local2> <0421525d-8304-6142-04bd-4f564ca043c0@eastlink.ca>

On Wed, Mar 24, 2021 at 6:45 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote: > > I'd think of it as polite. Just now I'm doing this: > > (( divided = sum * 1.0 / level )) > > ... and it really does seem belabored. Doc, Arithmetic Evaluation section: Users should beware that, in common with many other programming languages but not software designed for calculation, the evaluation of an expression in zsh is taken a term at a time and promotion of integers to floating point does not occur in terms only containing integers. A typical result of this is that a division such as 6/8 is truncated, in this being rounded towards 0. The FORCE_FLOAT shell option can be used in scripts or functions where floating point evaluation is required throughout.

**Follow-Ups**:**Re: forcing float arithmetic.***From:*Ray Andrews

**References**:**forcing float arithmetic.***From:*Ray Andrews

**Re: forcing float arithmetic.***From:*Bart Schaefer

**Re: forcing float arithmetic.***From:*Ray Andrews

**Re: forcing float arithmetic.***From:*Roman Perepelitsa

**Re: forcing float arithmetic.***From:*Bart Schaefer

**Re: forcing float arithmetic.***From:*Ray Andrews

**Re: forcing float arithmetic.***From:*Daniel Shahaf

**Re: forcing float arithmetic.***From:*Ray Andrews

Messages sorted by: Reverse Date, Date, Thread, Author