zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: Peter Stephenson <p.w.stephenson@ntlworld.com>
Cc: zsh workers <zsh-workers@zsh.org>
Subject: Re: PATCH: Fix two bugs in typeset_setbase
Date: Mon, 4 May 2015 04:34:18 +0200	[thread overview]
Message-ID: <CAHYJk3RWp=kQ=VFt1+iqMgiQYpprUDLORVRE8hdy3DDgKTeiww@mail.gmail.com> (raw)
In-Reply-To: <CAHYJk3S7CnBdO5ZuEcz_a3RQgd4LK8zJgJ=-gOiH7zwgO=qJjQ@mail.gmail.com>

On Mon, May 4, 2015 at 12:40 AM, Mikael Magnusson <mikachu@gmail.com> wrote:
> On Sun, May 3, 2015 at 11:24 PM, Peter Stephenson
> <p.w.stephenson@ntlworld.com> wrote:
>> On Sun, 3 May 2015 22:43:46 +0200
>> Mikael Magnusson <mikachu@gmail.com> wrote:
>>> Perhaps we should apply some limit to the precision of floats? For example,
>>> typeset -F 100000000 foo; echo $foo
>>> succeeds, and at least in my setup, causes typing at the next
>>> commandline to be very slow, because of multiple calls to
>>> setunderscore(). It doesn't seem to affect zsh -f. This could also be
>>> a case of "don't do that then". :)
>>
>> Yes, it's not exactly a bug... but I guess it's easy to set it to some
>> documented ceiling where it's definitely not going to make a practical
>> difference.  100 or 1000?
>
> Came across this comment while poking around earlier (in
> params.c:convfloat()), I guess 1000 should be a very safe limit.
>
>     /*
>      * The difficulty with the buffer size is that a %f conversion
>      * prints all digits before the decimal point: with 64 bit doubles,
>      * that's around 310.  We can't check without doing some quite
>      * serious floating point operations we'd like to avoid.
>      * Then we are liable to get all the digits
>      * we asked for after the decimal point, or we should at least
>      * bargain for it.  So we just allocate 512 + digits.  This
>      * should work until somebody decides on 128-bit doubles.
>      */

Oops, the 310 text speaks of the digits before the decimal point (not
sure how I missed it, it's pretty explicit about it). I guess this
means the practical limit is different for -E and -F. I don't know
enough details for floats to make a reasonable suggestion (but
probably doing calculations with multiple thousand digits of precision
is not a job for the shell). I've committed my patch and if someone
wants to plop in a limit, be my guest (or tell me what to make it).

-- 
Mikael Magnusson


      reply	other threads:[~2015-05-04  2:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-03 19:21 'typeset -F' behaves unexpectedly for "-F 1" and "-F 0" David Hughes
2015-05-03 20:36 ` PATCH: Fix two bugs in typeset_setbase Mikael Magnusson
2015-05-03 20:43   ` Mikael Magnusson
2015-05-03 21:24     ` Peter Stephenson
2015-05-03 22:40       ` Mikael Magnusson
2015-05-04  2:34         ` Mikael Magnusson [this message]

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='CAHYJk3RWp=kQ=VFt1+iqMgiQYpprUDLORVRE8hdy3DDgKTeiww@mail.gmail.com' \
    --to=mikachu@gmail.com \
    --cc=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@zsh.org \
    /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/zsh/

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).