Zefram <[EMAIL PROTECTED]> wrote:
> Re: Patch for DateTime::Format::W3CDTF to respekt second fragment part
> 
> Julian Haupt wrote:
> >+    if ($date =~ s/\.(\d+)$// )
> >+    {
> >+   my $fraction = $1;
> >+   $p{'nanosecond'} = (1 / $fraction) * 10**9;
> >+    }
> 
> That inversion can't be right.  Surely you mathematically want
> 
>    $p{'nanosecond'} = "0.$fraction" * 10**9;
> 
> but actually the nanoseconds member is supposed to be an integer, and
> it would be better to avoid floating-point arithmetic entirely:
> 
>    $fraction = substr($fraction, 0, 9);
>    $fraction .= "0" x (9 - length($fraction);
>    $p{'nanosecond'} = 0 + $fraction;

Beware the picosecond!

Or, what happens if there are 10 digits after the decimal point.  I've no 
idea what -3 zeroes looks like, but the answer is unlikely to be correct.

Yeah, mostly academic, except I'm working towards a time type (not for 
Perl per se) that extends down to picoseconds (and up to 10^12 years, 
too).

-- 
Jonathan Leffler ([EMAIL PROTECTED])
STSM, Informix Database Engineering, IBM Information Management Division
4100 Bohannon Drive, Menlo Park, CA 94025-1013
Tel: +1 650-926-6921    Tie-Line: 630-6921
"I don't suffer from insanity; I enjoy every minute of it!"

NB: with effect from 2007-11-28, my address and phone number change to:
4400 N First St, San Jose, CA 95134-1257
Tel: +1 408-956-2436         T/L: 475-2436

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to