On Sat, 1 Sep 2018 at 12:31, Frank Millman wrote:
>
> "Frank Millman" wrote in message news:pm3l2m$kv4$1...@blaine.gmane.org...
> >
> > I know about this gotcha -
> >
> > >>> x = 1.1 + 2.2
> > >>> x
> > 3.3003
> >
> [...]
>
> I have enjoyed the discussion, and I have learnt a lot abou
On Sat, 01 Sep 2018 13:27:59 +0200, Frank Millman wrote:
from decimal import Decimal as D
f"{D('1.1')+D('2.2'):.60f}"
> '3.3000'
'{:.60f}'.format(D('1.1') + D('2.2'))
> '3.300
"Frank Millman" wrote in message news:...
"Frank Millman" wrote in message news:pm3l2m$kv4$1...@blaine.gmane.org...
I know about this gotcha -
>>> x = 1.1 + 2.2
>>> x
3.3003
[...]
I have enjoyed the discussion, and I have learnt a lot about floating point.
Thanks to all.
I
On Fri, 31 Aug 2018 18:45:16 +1200, Gregory Ewing wrote:
> Steven D'Aprano wrote:
>> The right way is to
>> set the rounding mode at the start of your application, and then let
>> the Decimal type round each calculation that needs rounding.
>
> It's not clear what you mean by "rounding mode" here
Steven D'Aprano wrote:
The right way is to
set the rounding mode at the start of your application, and then let the
Decimal type round each calculation that needs rounding.
It's not clear what you mean by "rounding mode" here. If you
mean whether it's up/down/even/whatever, then yes, you can
p
On Thu, 30 Aug 2018 19:22:29 +1200, Gregory Ewing wrote:
> Steven D'Aprano wrote:
>> Why in the name of all that's holy would anyone want to manually round
>> each and every intermediate calculation when they could use the Decimal
>> module and have it do it automatically?
>
> I agree that Decima
Steven D'Aprano wrote:
Why in the name of all that's holy would anyone want to manually round
each and every intermediate calculation when they could use the Decimal
module and have it do it automatically?
I agree that Decimal is the safest and probably easiest way to
go, but saying that it "d
On Wed, 29 Aug 2018 11:31:29 +1200, Gregory Ewing wrote:
> Frank Millman wrote:
>> I have been trying to explain why
>> they should use the decimal module. They have had a counter-argument
>> from someone else who says they should just use the rounding technique
>> in my third example above.
>
>
On Tue, 28 Aug 2018 16:47:25 +0200, Frank Millman wrote:
> The reason for my query is this. I am assisting someone with an
> application involving monetary values. I have been trying to explain why
> they should use the decimal module. They have had a counter-argument
> from someone else who says
On Tue, 28 Aug 2018 at 15:50, Frank Millman wrote:
>
> "Frank Millman" wrote in message news:pm3l2m$kv4$1...@blaine.gmane.org...
> >
> > I know about this gotcha -
> >
> > >>> x = 1.1 + 2.2
> > >>> x
> > 3.3003
> >
> [...]
> >
> > >>> y = 3.3
> > >>> y
> > 3.3
> >
> [...]
> >
> > >>>
Frank Millman wrote:
I have been trying to explain why
they should use the decimal module. They have had a counter-argument
from someone else who says they should just use the rounding technique
in my third example above.
It's possible to get away with this by judicious use of rounding.
There
On 08/28/2018 07:11 AM, Frank Millman wrote:
Hi all
I know about this gotcha -
x = 1.1 + 2.2
x
3.3003
According to the docs, the reason is that "numbers like 1.1 and 2.2 do
not have exact representations in binary floating point."
So when I do this -
y = 3.3
y
3.3
what exa
On 2018-08-28 15:11, Frank Millman wrote:
Hi all
I know about this gotcha -
x = 1.1 + 2.2
x
3.3003
According to the docs, the reason is that "numbers like 1.1 and 2.2 do not
have exact representations in binary floating point."
So when I do this -
y = 3.3
y
3.3
what exactly
On Wed, Aug 29, 2018 at 12:47 AM, Frank Millman wrote:
> They were interesting, but actually did not answer the question that I
> forgot to ask!
>
> The reason for my query is this. I am assisting someone with an application
> involving monetary values. I have been trying to explain why they shoul
"Frank Millman" wrote in message news:pm3l2m$kv4$1...@blaine.gmane.org...
I know about this gotcha -
>>> x = 1.1 + 2.2
>>> x
3.3003
[...]
>>> y = 3.3
>>> y
3.3
[...]
>>> z = (1.1 + 2.2) * 10 / 10
>>> z
3.3
Thanks to Chris and Stephen for the replies.
They were interestin
On 2018-08-28, Frank Millman wrote:
x = 1.1 + 2.2
x
> 3.3003
>
> According to the docs, the reason is that "numbers like 1.1 and 2.2 do not
> have exact representations in binary floating point."
Right.
> So when I do this -
>
y = 3.3
y
> 3.3
>
> what exactly is
Hi Frank,
One difference is that, in order to carry out the instructions embodied in
the first example, the computer has to perform arithmetic. And it adds the
binary approximation of 1.1 (which is very slightly wrong) to the binary
approximation of 2.2 (which, again, is very slightly wrong). It t
On Wed, Aug 29, 2018 at 12:11 AM, Frank Millman wrote:
> Hi all
>
> I know about this gotcha -
>
x = 1.1 + 2.2
x
>
> 3.3003
>
> According to the docs, the reason is that "numbers like 1.1 and 2.2 do not
> have exact representations in binary floating point."
>
> So when I do
18 matches
Mail list logo