Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: Fix two bugs in typeset_setbase



On Sun, May 3, 2015 at 11:24 PM, Peter Stephenson
<p.w.stephenson@xxxxxxxxxxxx> wrote:
> On Sun, 3 May 2015 22:43:46 +0200
> Mikael Magnusson <mikachu@xxxxxxxxx> 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.
     */


-- 
Mikael Magnusson



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