[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [minor] "precision" of $SECONDS
From: |
Stephane Chazelas |
Subject: |
Re: [minor] "precision" of $SECONDS |
Date: |
Thu, 25 Feb 2016 17:20:16 +0000 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
2016-02-25 10:48:51 -0500, Chet Ramey:
[...]
> Because bash doesn't have floating point arithmetic.
Yes, makes sense. mksh having $EPOCHREALTIME floating point even
though it doesn't have floating point arithmetic does sound
weird.
Any plan of adding floating point arithmetic support to bash by
the way?
> There's no
> real reason to have $SECONDS in a format you can't use to perform
> calculations.
That could be done with an extra $NANOSECONDS variable, but then
that wouldn't be reliable as in now=$SECONDS.$NANOSECONDS,
$SECONDS and $NANOSECONDS could be expanded at different seconds
(if run for instance at 00:00:00.9999999).
A printf '%(sec=%s nsec=%N)T' -1 wouldn't have the problem though.
> Bash's %T implementation doesn't have %N because it uses the libc
> strftime(3), and as far as I know, no strftime provides it. I assume
> that ksh93 implements it internally as part of libast.
[...]
Probably. Note that GNU date also has a %N and doesn't use
strftime either. strftime taking a struct tm can't have
subseconds anyway.
--
Stephane