bug-gawk
[Top][All Lists]
Advanced

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

Re: How are numbers printed in gawk?


From: arnold
Subject: Re: How are numbers printed in gawk?
Date: Wed, 18 Mar 2020 02:37:04 -0600
User-agent: Heirloom mailx 12.5 7/5/10

Peng Yu <address@hidden> wrote:

> Hi,
>
> I'd like to write some python code that produces the same results as
> gawk for numbers. As far as I understand there is no integer type in
> gawk internal. But if I use float in python for integer, python will
> print something like 1.0. Therefore, I'd like to know gawk is
> implemented regarding numbers. Could anybody show the best approach to
> implement the same method used in awk dealing with numbers in python?
> Thanks.
>
> $ awk 'BEGIN { print .0 + 1 }'
> 1
> $ python -c 'print(.0 + 1)'
> 1.0
>
> -- 
> Regards,
> Peng

$ python -c "print('%.0f' % 1.0)"
1

Please take any further python questions elsewhere.

Thanks,

Arnold



reply via email to

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