Python论坛  - 讨论区

标题:[python-chinese] -25.5 % 2.25

2005年05月16日 星期一 09:45

=?GB2312?B?hKLA2g==?= liul at dhc.com.cn
Mon May 16 09:45:19 HKT 2005

非常感谢,回复简洁明了,通俗易懂!


----- Original Message ----- 
From: "orciloud tang" <orciloud at gmail.com>
To: "python-chinese" <python-chinese at lists.python.cn>
Sent: Monday, May 16, 2005 11:34 AM
Subject: FW: [python-chinese] -25.5 % 2.25



------ Forwarded Message
From: DengWei <salala_mud at 163.com>
Organization: 辽宁省辽阳市宏伟区光华街30号沈阳工业大学辽阳校区89号信箱
Reply-To: <salala_mud at 163.com>
Date: Mon, 16 May 2005 10:30:06 +0800
To: orciloud tang <orciloud at gmail.com>
Subject: Re: [python-chinese] -25.5 % 2.25

想起来公式了……
还是我来给答案吧  ^_^ 这是进 Python list 后每时一次回答问题

  A % B 如果不同号的话,那公运算公式为 A % B = B的符号(B的绝对值 - ( A的绝对
值 % B的绝对值 ))    括号里的 % 为正常求余运算
  A % B 同号,按正常求余方法算

  -25.5 % 2.25 = +(2.25 - ( 25.5 % 2.25 )) = +(2.25 - 0.75) = +1.5


在 Mon, 16 May 2005 10:24:19 +0800,orciloud tang <orciloud at gmail.com> 写
道:

>
> 应该是
>
> - 和 % 的优先级的问题。。。见我上封email...25.5
>
>
> On 5/16/05 10:18 AM, "DengWei" <salala_mud at 163.com> wrote:
>
>> 个人感觉这个可能和 FoxBase 里的求余运算的算法一样。
>> 具体公式忘了……反正不是我们平常用的求余方法。
>>
>> 在 Mon, 16 May 2005 10:07:09 +0800,orciloud tang <orciloud at gmail.com>
>>>> 道:
>>
>>>
>>> 奇怪
>>> [orciloud at apple Versions]$pike
>>> Pike v7.6 release 24 running Hilfe v3.5 (Incremental Pike Frontend)
>>>> -25.5 % 2.25
>>>>> ;
>>> (1) Result: 1.500000
>>>>
>>>> [orciloud at apple Versions]$
>>> [orciloud at apple Versions]$echo -25.5 % 2.25|bc
>>> -.75
>>>
>>>
>>> Pike 计算出来也是1.5
>>> 但bc计算出来是 0.75
>>> 同样疑惑
>>>
>>>
>>> On 5/16/05 9:00 AM, "刘磊" <liul at dhc.com.cn> wrote:
>>>
>>>> -25.5 % 2.25在python2.4下结果是1.5
>>>> 但计算器算出来的却是-0.75
>>>> 用java计算出来也是-0.75
>>>> 不得要领,望各位指教,不胜感激!
>>>>
>>>> _______________________________________________
>>>> python-chinese list
>>>> python-chinese at lists.python.cn
>>>> http://python.cn/mailman/listinfo/python-chinese
>>>
>>>
>>> _______________________________________________
>>> python-chinese list
>>> python-chinese at lists.python.cn
>>> http://python.cn/mailman/listinfo/python-chinese
>>>
>>
>>
>
>
>



-- 
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/


------ End of Forwarded Message


_______________________________________________
python-chinese list
python-chinese at lists.python.cn
http://python.cn/mailman/listinfo/python-chinese 


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2005年05月16日 星期一 10:22

Bruce Who whoonline at msn.com
Mon May 16 10:22:46 HKT 2005

DQoJMS41us0tMC43NLa8ysfV/ci3tcS94bn7o6zS8s6qx/PT4Mr9tcS94bn7srvKx86o0ru1xKOs
v7TE49T1w7TIocHLoaMNCg0KPT09PT09PSAyMDA1LTA1LTE2IDA5OjAwOjIxIISiwNogd3JvdGU6
ID09PT09PT0NCg0KPi0yNS41ICUgMi4yNdTacHl0aG9uMi40z8K94bn7yscxLjUNCj61q7zGy+PG
98vjs/bAtLXEyLTKxy0wLjc1DQo+08NqYXZhvMbL47P2wLTSssrHLTAuNzUNCj6yu7XD0qrB7KOs
zfu498671ri9zKOssrvKpLjQvKSjoSANCj4NCj5fX19fX19fX19fX19fX19fX19fX19fX19fX19f
X19fX19fX19fX19fX19fX19fXw0KPnB5dGhvbi1jaGluZXNlIGxpc3QNCj5weXRob24tY2hpbmVz
ZUBsaXN0cy5weXRob24uY24NCj5odHRwOi8vcHl0aG9uLmNuL21haWxtYW4vbGlzdGluZm8vcHl0
aG9uLWNoaW5lc2UNCj4uDQoNCj0gPSA9ID0gPSA9ID0gPSA9ID0gPSA9ID0gPSA9ID0gPSA9ID0g
PQ0KCQkJDQpCZXN0IHJlZ2FyZHMsDQoNCqGhoaGhoaGhoaGhoaGhoaFCcnVjZSBXaG8NCqGhoaGh
oaGhoaGhoaGhoaGhoaGhMjAwNS0wNS0xNg0KDQo=

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2005年05月16日 星期一 10:28

orciloud tang orciloud at gmail.com
Mon May 16 10:28:25 HKT 2005

水又来了,今天不再发水了,

还是这位兄弟这样说的,,
因为我又迷惑了。。


[orciloud at apple orciloud]$echo "(-25.5)%2.25"|bc
-.75
[orciloud at apple orciloud]$echo "(25.5)%2.25"|bc
.75
[orciloud at apple orciloud]$echo "-(25.5%2.25)"|bc
-.75


On 5/16/05 10:22 AM, "Bruce Who" <whoonline at msn.com> wrote:

> 
> 1.5和-0.74都是正确的结果,因为求余数的结果不是唯一的,看你怎么取了。
> 
> ======= 2005-05-16 09:00:21 刘磊 wrote: =======
> 
>> -25.5 % 2.25在python2.4下结果是1.5
>> 但计算器算出来的却是-0.75
>> 用java计算出来也是-0.75
>> 不得要领,望各位指教,不胜感激!
>> 
>> _______________________________________________
>> python-chinese list
>> python-chinese at lists.python.cn
>> http://python.cn/mailman/listinfo/python-chinese
>> .
> 
> = = = = = = = = = = = = = = = = = = = =
> 
> Best regards,
> 
>         Bruce Who
>           2005-05-16
> 
> _______________________________________________
> python-chinese list
> python-chinese at lists.python.cn
> http://python.cn/mailman/listinfo/python-chinese



[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2005年05月16日 星期一 10:49

the13thday evil.the13thday at gmail.com
Mon May 16 10:49:29 HKT 2005

tdrSu7TOvdO0paOstPOzpLz7yrajoQoK1NowNS01LTE2o6yEosDaPGxpdWxAZGhjLmNvbS5jbj4g
0LS1wKO6Cj4gt8ezo7jQ0LujrLvYuLS88r3gw/fBy6OszajL19LXtq6joQo+IAo+IAo+IC0tLS0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BNZXNzYWdlCj4gCj4gX19fX19fX19fX19fX19fX19fX19f
X19fX19fX19fX19fX19fX19fX19fX19fX18KPiBweXRob24tY2hpbmVzZSBsaXN0Cj4gcHl0aG9u
LWNoaW5lc2VAbGlzdHMucHl0aG9uLmNuCj4gaHR0cDovL3B5dGhvbi5jbi9tYWlsbWFuL2xpc3Rp
bmZvL3B5dGhvbi1jaGluZXNlCj4gCj4gX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f
X19fX19fX19fX19fX18KPiBweXRob24tY2hpbmVzZSBsaXN0Cj4gcHl0aG9uLWNoaW5lc2VAbGlz
dHMucHl0aG9uLmNuCj4gaHR0cDovL3B5dGhvbi5jbi9tYWlsbWFuL2xpc3RpbmZvL3B5dGhvbi1j
aGluZXNlCj4K

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2005年05月17日 星期二 15:55

nester chao nester_chao at yahoo.com.cn
Tue May 17 15:55:52 HKT 2005

在计算机界, 关于%操作一般情况下是这样定义的.

x%y = x - x/y*y 
其中, x/y的结果要取整.

x, y符号不同时,
根据x/y向右和向左取整(各种语言有各自不同实现),
x%y就可能有不同的值.

例:
令x为-25.5
  y为2.25

当 -25.5/2.25取整为-12时, (我们约定这里/的结果要取整)
-25.5/2.25 = 1.5
当 -25.5/2.25取整为-11时,
-25.5/2.25 =-0.75

_________________________________________________________
Do You Yahoo!?
150万曲MP3疯狂搜,带您闯入音乐殿堂
http://cn.rd.yahoo.com/mail_cn/tag/yisou/music/*http://music.yisou.com/
美女明星应有尽有,搜遍美图、艳图和酷图
http://cn.rd.yahoo.com/mail_cn/tag/yisou/image/*http://image.yisou.com
1G就是1000兆,雅虎电邮自助扩容!
http://cn.rd.yahoo.com/mail_cn/tag/1g/*http://cn.mail.yahoo.com/event/mail_1g/

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号