Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: inconsistent long number truncation
- X-seq: zsh-workers 43661
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: inconsistent long number truncation
- Date: Tue, 9 Oct 2018 13:30:04 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:to:subject:message-id:references :mime-version:content-type:in-reply-to; s=fm1; bh=v2/4yuMBaxXfj6 HcnV2elLRuti03GCzkfGfn4YdDowY=; b=U9Q+5Ju2Cw/OjzCHWGa57TQsJ1pebG IMC+IhyEiKGO69TQ8Y+XcZd3w0iKujkDaHv/CQ2QT20BVpZfgioUr0Uy6EVj/lT8 3iQSUHGvpgZPgSyxXh/VqYpwj5Ir3dfFs4ppclPLN72p6/voAIoIajQoeIVY2qLS AUEO1p/x2xtzXrOeY4f/BO5ZJf4aAuk0ufiDzD4tbeHcUePiat2xIsKGWh5IokdT KlJbqIJ9p1yDDgAQhg0lADKowG0CZL9nws49DqOKnkfnJGKPdYCB48QbWxgsi+zR EPriXjNpsvCYQvvglzPNJX/gpPS1GO8rzHIPvGGeZcNuvjHfbz1i364w==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=v2/4yu MBaxXfj6HcnV2elLRuti03GCzkfGfn4YdDowY=; b=XMkbj7UvWYzASfBJSMoN7P 4AN3bRGTkybbTklb/T7oEOeFSjx249RM2TW9LY6dM8eZirAOXIhHbk+ZgIKEHvPv Nlb9EJ7L6+QtEw7IcGu83I3a0Gf2G6uZTE8J9M44e8p7YW/OsMAtZCLrtygAP/Eb ZUgJQakmGZhhzw4ZRZnA8UfoU2TjHzYOE0wYsLpi5Ww0gysQvbIEddwQ9fXHiJxs iuqsbDSllFt2Ofh7NNFOM237t2wpa81uolhVH4uVXNNoKwXkapnNMNGPY40Rrfyj NruYUSa5q9IMkY5Xgu9blFNp4MzddmF5UEL1Cjq7kDH/bHzFcvXazB2dgRbq4PnA ==
- In-reply-to: <20181009065014.6rxe67ophjq6j6vs@chaz.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20181009065014.6rxe67ophjq6j6vs@chaz.gmail.com>
Stephane Chazelas wrote on Tue, Oct 09, 2018 at 07:50:14 +0100:
> I think the:
>
>
> newcalc = calc * base + *s - '0';
> if (newcalc < calc)
>
> Is an invalid way to check for numbers wrapping.
>
Obviously right, as your examples show:
> (gdb) p calc
> $7 = 12345678901234567890
> (gdb) p calc*10
> $8 = 12776324570088369204
> Why do we truncate in the first place?
Judging by the comment at the top of the function, might that be for
compatibility with some strtol() implementation [that once was] out there?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author