bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Arithmetic strange behaviour on numbers bigger than 0xFFFFFFFFFFFFF


From: Aharon Robbins
Subject: Re: Arithmetic strange behaviour on numbers bigger than 0xFFFFFFFFFFFFF
Date: Mon, 15 Nov 2010 21:19:08 +0200
User-agent: Heirloom mailx 12.4 7/29/08

Hi.

Gawk does not really support 64 bit integers. Values get converted back
and forth between double and uintmax_t variables for the bitwise operations,
but double can't hold the full range of values that a 64 bit integer can,
and in this case you're using doubles.

Sorry,

Arnold

> Subject: Arithmetic strange behaviour on numbers bigger than 0xFFFFFFFFFFFFF
> Date: Mon, 15 Nov 2010 17:53:20 +0100
> From: "BEAUGY Alexandre" <address@hidden>
> To: <address@hidden>
>
> Dear all,
>
> Today, I experienced the following strange behaviour of gawk:
>
> $ gawk 'BEGIN{x=0xA000000000000}{++x}{print x}' input.file
> 2814749767106561
> 2814749767106562
> 2814749767106563
> 2814749767106564
>
> $ gawk 'BEGIN{x=0xA0000000000000}{++x}{print x}' input.file
> 45035996273704960
> 45035996273704960
> 45035996273704960
> 45035996273704960
>
> How could that be? Why is my counter incremented in one case and not in
> the other one? Did I correctly use awk? Or didn't I?
>
> I read that gawk was able to manipulate 64-bits integer. That's why I
> incremented such a big counter, in my awk script.
>
> Thanks a lot in advance.
>
> Regards,
> -- 
> Alexandre BEAUGY



reply via email to

[Prev in Thread] Current Thread [Next in Thread]