在数字上 [英] On Numbers

查看:76
本文介绍了在数字上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在平等的讨论中,十进制(''''')== 3.0的问题是

False出现了改变==行为的原因。这个问题

这个建议的改变并没有真正解决任何问题,它只是给出了不同的错误行为。正确的解决办法似乎是修复python'处理数字的问题。


PEP不清楚为什么总是要测试相等性失败。虽然PEP表示与浮动的交互被禁止为对于b
棘手,但比较似乎是一个例外。特别是,平等

比较似乎总是返回假,而检查

幅度似乎也有效。


看来缺少Python是所有

数字类型的连贯模型。其他语言都有这个,所以Python没有明显的原因。或者也许是Python,我忽略了它的价值。在这种情况下,指向文档的指针将不胜感激。

如果它不存在,那么我认为这应该是为Py3K提供的



我想继续努力。我们的想法是,所有数字类型

都是具有不同属性的实数的表示,使得它们适合不同的用途。目标是一个

数字类型的模型,它以一种允许它们组合的方式捕获这些属性,以便在没有狡猾的情况下提供合理的行为。 。


为了开始这个,我想考虑其他语言如何使用丰富的数字类型系统来构建它们。我将在LISP系列中查看几种

语言。我想向社区征求

语言的名称(以及引用的指针,如果可能!)和

a一组丰富的数字类型的连贯视图。


谢谢,

< mike

-

Mike Meyer< mw * @ mired.org> http://www.mired.org/home/mwm/

独立的WWW / Perforce / FreeBSD / Unix顾问,电子邮件以获取更多信息。

In the discussion of equality, the issue that decimal(''3.0'') == 3.0 is
False came up as a reason for changing the behavior of ==. The problem
with this is that the proposed change doesn''t really fix anything, it
just gives different wrong behavior. The correct fix would seem to be
fixing python''s handling of numbers.

It''s not clear from the PEP why test for equality always fails. While
the PEP says that interactions with floats are disallowed as "to
tricky", comparisons seem to be an exception. In particular, equality
comparisons seem to always return false, whereas checking for
magnitude seems to work.

What appears to be missing in Python is a coherent model for all
numberic types. Other languages have this, so there''s no obvious
reason that Python can''t. Or maybe Python does, and I''ve overlooked
it. In that case, pointers to documentation would be appreciated.
If it doesn''t exist, then I think this is something that should be
addressed for Py3K.

I''d like to work on that. The idea would be that all the numeric types
are representations of reals with different properties that make them
appropriate for different uses. The goal would be a model for a
numeric type that captures those properties in a way that allows them
to be combined to give sane behavior without being "to tricky".

To get started on that, I want to consider how other languages with
rich numeric type systems model them. I''m going to look at a couple of
languages in the LISP family. I''d like to solicit the community for
the names of languages (and pointers to references, if possible!) with
a coherent view of a rich set of numeric types.

Thanks,
<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

推荐答案

2006年1月14日星期六18 :18:12-0500,

Mike Meyer< mw*@mired.org>写道:
On Sat, 14 Jan 2006 18:18:12 -0500,
Mike Meyer <mw*@mired.org> wrote:
...建议的更改并没有真正解决任何问题,它只是给出了不同的错误行为......


:-)

为了开始这个,我想考虑其他语言如何使用丰富的数字类型系统对它们进行建模。我将在LISP家族中查看几种语言。我想向社区征求
语言的名称(以及引用的指针,如果可能的话!)和
一组丰富的数字类型的连贯视图。
... the proposed change doesn''t really fix anything, it just gives
different wrong behavior ...
:-)
To get started on that, I want to consider how other languages with
rich numeric type systems model them. I''m going to look at a couple of
languages in the LISP family. I''d like to solicit the community for
the names of languages (and pointers to references, if possible!) with
a coherent view of a rich set of numeric types.




右上角,Common Lisp。


寻找Guy L. Steele的_Common Lisp的论文或在线副本

语言_,第2版。一个快速的谷歌搜索说,CMU的主人

在线副本现在无法正常工作。


或者从< http:/开始/www.lisp.org/HyperSpec/FrontMatter/index.html>和

点击第12章,< http://www.lisp.org/HyperSpec/Body/chap-12.html>。


问候,

Dan


-

Dan Sommers

< http:// www。 tombstonezero.net/dan/>



Go right to the top, Common Lisp.

Seek out a paper or on-line copy of Guy L. Steele''s _Common Lisp The
Language_, 2nd edition. A quick google search says that the "master"
online copy at CMU is not working correctly right now.

Or start at <http://www.lisp.org/HyperSpec/FrontMatter/index.html> and
click to Chapter 12, <http://www.lisp.org/HyperSpec/Body/chap-12.html>.

Regards,
Dan

--
Dan Sommers
<http://www.tombstonezero.net/dan/>


2006年1月14日星期六18:18:12 -0500,Mike Meyer< mw*@mired.org>写道:
On Sat, 14 Jan 2006 18:18:12 -0500, Mike Meyer <mw*@mired.org> wrote:
在讨论平等时,十进制(''''')== 3.0的问题是错误的,这是改变行为的一个原因。 ==。这个问题是建议的改变并没有真正解决任何问题,它只会给出不同的错误行为。正确的解决办法似乎是修复python对数字的处理。

PEP不清楚为什么测试平等总是失败。虽然PEP表示与浮动的交互不被视为棘手,但比较似乎是一个例外。特别是,平等比较似乎总是返回错误,而检查
幅度似乎是有效的。

Python中似乎缺少的是所有人的连贯模型数字类型。其他语言都有这个,所以Python没有明显的原因。或者也许是Python,我忽略了它。在这种情况下,指向文档的指针将不胜感激。
如果它不存在,那么我认为这是应该为Py3K解决的问题。

我'我想继续努力。我们的想法是所有数字类型都是具有不同属性的实数的表示,这些属性使它们适合不同的用途。目标将是一个
数字类型的模型,它以一种允许它们组合的方式捕获这些属性,以便在没有棘手的情况下提供合理的行为。
为了开始,我想考虑其他语言如何使用丰富的数字类型系统对它们进行建模。我将在LISP家族中查看几种语言。我想向社区征求
语言的名称(以及引用的指针,如果可能的话!)和
一组丰富的数字类型的连贯视图。
In the discussion of equality, the issue that decimal(''3.0'') == 3.0 is
False came up as a reason for changing the behavior of ==. The problem
with this is that the proposed change doesn''t really fix anything, it
just gives different wrong behavior. The correct fix would seem to be
fixing python''s handling of numbers.

It''s not clear from the PEP why test for equality always fails. While
the PEP says that interactions with floats are disallowed as "to
tricky", comparisons seem to be an exception. In particular, equality
comparisons seem to always return false, whereas checking for
magnitude seems to work.

What appears to be missing in Python is a coherent model for all
numberic types. Other languages have this, so there''s no obvious
reason that Python can''t. Or maybe Python does, and I''ve overlooked
it. In that case, pointers to documentation would be appreciated.
If it doesn''t exist, then I think this is something that should be
addressed for Py3K.

I''d like to work on that. The idea would be that all the numeric types
are representations of reals with different properties that make them
appropriate for different uses. The goal would be a model for a
numeric type that captures those properties in a way that allows them
to be combined to give sane behavior without being "to tricky".

To get started on that, I want to consider how other languages with
rich numeric type systems model them. I''m going to look at a couple of
languages in the LISP family. I''d like to solicit the community for
the names of languages (and pointers to references, if possible!) with
a coherent view of a rich set of numeric types.



我想你已经找到了scheme的rsr5规范,例如,
http://www.schemers.org/Documents/Standards/R5RS/


在考虑数字时,等价问题是把我们带到这里

也在计划中探讨
http://www.schemers.org/Documents/St...html#%_sec_6.1

和后面的数字部分
http://www.schemers.org/Documents/St...html#%_sec_6.2


for common LISP <无线电通信/> http://www.lispworks.com/documentati。 ..ront / index.htm

你也可以追逐很多有趣的链接(虽然有些死了)来自
http://www.cetus-links.org/oo_clos.html

cltl2在
http://www.cs .cmu.edu / Groups / AI / html / cltl / cltl2.html


现在尝试完成一些工作;-)


BTW,IIRC Ada的数字包括一些有趣的条款,用于表示数字

的固定点,具有指定的分数精度

我google并找到了
http://www.adaic.org/标准/ 95lrm / html / RM-0-1.html

浏览一下,scal ar类型在
http: //www.adaic.org/standards/95lrm/html/RM-3-5.html

整数包括通过模块化定义的无符号
http://www.adaic.org/standards/ 95lrm / html / RM-3-5-4.html

这里是固定点
http://www.adaic.org/standards/95lrm/html/RM-3-5-9 .html

哇,因为阿达是绿色,我几乎没有进入那些东西。 ;-)

让我想知道发电机是否可以有效地进行会合(''?, es?);-)


问候,

Bengt Richter


I suppose you have already found scheme''s rsr5 spec, e.g.,
http://www.schemers.org/Documents/Standards/R5RS/

while thinking about numbers, the issue of equivalence that got us here
is also explored in scheme
http://www.schemers.org/Documents/St...html#%_sec_6.1
and the section that follows in on numbers
http://www.schemers.org/Documents/St...html#%_sec_6.2

for common lisP
http://www.lispworks.com/documentati...ront/index.htm
you can also chase lots of interesting links (some dead though) from
http://www.cetus-links.org/oo_clos.html
cltl2 is at
http://www.cs.cmu.edu/Groups/AI/html/cltl/cltl2.html

Now try to get some work done ;-)

BTW, IIRC Ada''s numbers include some interesting provisions for representing numbers
in fixed point with specified fractional accuracy
I google and found
http://www.adaic.org/standards/95lrm/html/RM-0-1.html
browsing a bit, scalar types are at
http://www.adaic.org/standards/95lrm/html/RM-3-5.html
integers include unsigned by way of genera modular definition
http://www.adaic.org/standards/95lrm/html/RM-3-5-4.html
and here is the fixed point
http://www.adaic.org/standards/95lrm/html/RM-3-5-9.html
Whoo, I haven''t been into that stuff almost since Ada was "green" ;-)
Makes me wonder if generators could usefully have rendezvous(''?, es?) ;-)

Regards,
Bengt Richter


Mike Meyer< mw*@mired.org>写道:
Mike Meyer <mw*@mired.org> writes:
我想继续努力。我们的想法是所有数字类型都是具有不同属性的实数的表示,这些属性使它们适合不同的用途。
I''d like to work on that. The idea would be that all the numeric types
are representations of reals with different properties that make them
appropriate for different uses.




2+ 3j?



2+3j?


这篇关于在数字上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆