Re: accuracy of Time::HiRes




"Anonymous coward" <anonymous@xxxxxxx> wrote in message
news:bdb84$48655840$89e0e08f$8931@xxxxxxxxxxxxxxxxxxx
On Fri, 27 Jun 2008 21:38:39 +0100, John wrote:

Hi

use Time::HiRes qw (gettimeofday);
my ($secs,$milliseconds)=gettimeofday(); my $trans="$secs$milliseconds";
# 10 digits and 6 digits

Sometimes the length of $trans is 16 but sometimes it is 15. Shouldn't
it be 16 always?

Regards
John

The length of microseconds (not milliseconds) will be 5 digits one out of
ten times, because it's value is less than 100000 microseconds. In one
out of a hundred times it will be 4 digits, etc. If you rely on the
length of it, you should probably use sprintf.

Regards,

Leon Timmermans

Hi

Of course, I see that now. I need the length to create a unique number of
standard length. sprintf will do that.
Many thanks.

Regards
John



.



Relevant Pages

  • Re: Playing with Numbers
    ... > if not add zero/s in front to make it 5 digits. ... with the sprintf - cf perldoc -f sprintf, ... sub five_wide ...
    (perl.beginners)
  • Re: sprintf formating
    ... > change the dot to a comma and round the decimals to 2 digits. ... sprintf() can help with the rounding part. ... > how should i write the sprintf format to acheive the above format? ...
    (comp.lang.perl.misc)
  • sprintf(%.75g,0.03) behavior
    ... In a recent post there were examples of sprintf given that printed all of the decimal digits of an IEEE double number. ...
    (comp.soft-sys.matlab)
  • Re: string manipulation algorithm or function
    ... You're in luck, there's one in the standard library. ... Use field width specifier with sprintf ... If it's possible for the digits of your input to exceed the field width, ...
    (alt.comp.lang.learn.c-cpp)
  • Re: accuracy of Time::HiRes
    ... # 10 digits and 6 digits ... Sometimes the length of $trans is 16 but sometimes it is 15. ... because it's value is less than 100000 microseconds. ... Leon Timmermans ...
    (comp.lang.perl.misc)