D
Dr John Stockton
JRS: In article <[email protected]>
, dated Wed, 10 May 2006 10:08:51 remote, seen in
Richard Cornford
But you did not use format.
In code posted by an inexperienced or naive user, one should half-expect
that code formatting float dollars to dollars point integer cents will
be wrong.
The code earlier recommended in this group was wrong (I can't recall
whether it was in the FAQ; ISTR that it failed with 0.07).
Code posted here by newcomers since the present FAQ 4.6 was written has
been wrong.
The OP's job should evidently produce exact integer cents as a result of
the arithmetic, if implemented in decimal arithmetic. It may well be
that it actually produces, sometimes, an undersize Double, and that the
OP's format includes Math.floor().
If there is a difference in numerical value between input strings ".7"
and ".70". then the OP has a problem outside format.
To get anywhere, the OP should either learn javascript including the
implications of using IEEE Doubles, or he should post a cut-down version
of his code, complete and ready to run, with an exact statement of
sample data that it uses and what good and bad results that data gives.
, dated Wed, 10 May 2006 10:08:51 remote, seen in
Richard Cornford
Once again the output from this function should not be expected to
produce differing results for input of quantity '3' or '6' and unit
price '.7' and '.70', and it does not:-
But you did not use format.
In code posted by an inexperienced or naive user, one should half-expect
that code formatting float dollars to dollars point integer cents will
be wrong.
The code earlier recommended in this group was wrong (I can't recall
whether it was in the FAQ; ISTR that it failed with 0.07).
Code posted here by newcomers since the present FAQ 4.6 was written has
been wrong.
The OP's job should evidently produce exact integer cents as a result of
the arithmetic, if implemented in decimal arithmetic. It may well be
that it actually produces, sometimes, an undersize Double, and that the
OP's format includes Math.floor().
If there is a difference in numerical value between input strings ".7"
and ".70". then the OP has a problem outside format.
To get anywhere, the OP should either learn javascript including the
implications of using IEEE Doubles, or he should post a cut-down version
of his code, complete and ready to run, with an exact statement of
sample data that it uses and what good and bad results that data gives.