如何重新定义算术运算符。 [英] How to redefine arithmetic operators.

查看:112
本文介绍了如何重新定义算术运算符。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我需要你的帮助,如何在
C中重新定义算术运算符的功能。


例如:如果有一个等式c = a / b;


i想要为除法运算符执行我自己的算法。

我是被迫使用本机C,而不是调用函数或使用

宏进行算术运算。

我的意思是我被迫不使用c = MYDIV(a,b或者类似的东西。


我需要在PC上模拟MPC5554的浮点单元。在MPC中,

方式舍入,溢出,错误处理不同于P4

或AMD中使用的那些。


因此我需要模拟MPC5554的浮点运算,当我需要
$时b $ b来模拟为它设计的代码。

我希望我能够清楚地表达我的问题。


我们的帮助和建议是在最早的。


谢谢和最好的问候s

Raghu。

Hello all,

I need your help on how to redefine teh function of arithmetic operators in
C.

for example : if there is an equation c = a/b;

i want to execute my own algorithm for division operator.
I am compelled to use the native C , instead of calling functions or using
macros for doing arithmetic operations.
I mean i was compelled not to use c =MYDIV(a,b) or somewthing like that.

This i needeed to simulate floating point unit of MPC5554 on PC.In MPC the
way the rounding , overflow,errors dealt is different from those used in P4
or AMD.

so i need to simulate the floating point arithmetic of MPC5554 , when i want
to simualte the code designed for it.
I hope i could able express my question clearly.

Your help and advice is sought after at the earliest.

Thanks and Best Regards
Raghu.

推荐答案

Le 29-11-2005,Raghu< ra *** ************@in.bosch.com> écrit*:
Le 29-11-2005, Raghu <ra***************@in.bosch.com> a écrit*:
我需要你的帮助,如何重新定义算术运算符的功能。

例如:如果有一个等式c = a / b;

我想为分区运算符执行自己的算法。
我不得不使用本机C,而不是调用函数或使用
宏进行算术运算操作。
我的意思是我被迫不使用c = MYDIV(a,b)或类似的东西。
I need your help on how to redefine teh function of arithmetic operators in
C.

for example : if there is an equation c = a/b;

i want to execute my own algorithm for division operator.
I am compelled to use the native C , instead of calling functions or using
macros for doing arithmetic operations.
I mean i was compelled not to use c =MYDIV(a,b) or somewthing like that.




c = MYDIV之间的差异( a,b)和c = a / b只是''syntaxic

sugar''。

如果你真的需要重载运算符,你可以用C ++来实现,

但是没有办法在C中完成。


Marc Boyer



The difference between c=MYDIV(a,b) and c=a/b is only ''syntaxic
sugar''.
If you really need to overload operators, you can do it in C++,
but there is no way to do it in C.

Marc Boyer


Raghu a écrit:
Raghu a écrit :
大家好,

我需要你的帮助,如何重新定义算术运算符的功能。

例如:如果有一个等式c = a / b;

我想为除法运算符执行自己的算法。
我不得不使用本机C,而不是调用函数或使用
宏进行算术运算。
我的意思是我被迫不使用c = MYDIV(a,b)或类似的东西。

这个我需要在PC上模拟MPC5554的浮点单元。在MPC中的方式圆整,溢出,错误处理不同于P4
或AMD中使用的那些。

因此我需要模拟MPC5554的浮点运算,当我想要模拟为它设计的代码时。
我希望我能够清楚地表达我的问题。

我们最早会寻求你的帮助和建议。

感谢和最诚挚的问候
Raghu 。
Hello all,

I need your help on how to redefine teh function of arithmetic operators in
C.

for example : if there is an equation c = a/b;

i want to execute my own algorithm for division operator.
I am compelled to use the native C , instead of calling functions or using
macros for doing arithmetic operations.
I mean i was compelled not to use c =MYDIV(a,b) or somewthing like that.

This i needeed to simulate floating point unit of MPC5554 on PC.In MPC the
way the rounding , overflow,errors dealt is different from those used in P4
or AMD.

so i need to simulate the floating point arithmetic of MPC5554 , when i want
to simualte the code designed for it.
I hope i could able express my question clearly.

Your help and advice is sought after at the earliest.

Thanks and Best Regards
Raghu.



我害怕在这里开始新的火焰战争,但如果你接受

来使用*非标准* C, lcc-win32编译器允许你在不离开C框架的情况下执行运算符重载$


当然这是一个扩展,但它与标准兼容。

没有使用新的关键字。

http://www.cs.virinia.edu/~lcc-win32


jacob navia< ja *** @ jacob.remcomp.fr>写道:
jacob navia <ja***@jacob.remcomp.fr> writes:
Raghuaécrit:
Raghu a écrit :
我需要你的帮助,如何在
C中重新定义算术运算符的功能。
例如:如果有等式c = a / b;
[snip]
I need your help on how to redefine teh function of arithmetic
operators in
C.
for example : if there is an equation c = a/b; [snip]


我害怕在这里开始新的火焰战争,但是如果你接受使用*非标准* C,那么lcc-win32编译器可以让你在不离开C框架的情况下进行操作符重载。

当然这是一个扩展,但它与
标准兼容。没有使用新的关键字。


I am afraid to start a new flame war here, but if you accept
to use *non-standard* C, the lcc-win32 compiler allows you to
do operator overloading without leaving the framework of C.

Of course this is an extension, but it is compatible with the
standard. No new keywords are used.




在什么意义上这是不离开C的框架?


你不需要*操作员超载;任何你可以做的事情

它,你可以没有它(使用普通的函数调用)。


有些语言支持运算符重载:C ++,Ada,the扩展

lcc-win32和其他人支持的C语言。标准C本身

没有。 (当然,lcc-win32,顾名思义,对于32位Windows系统来说是有限的b $ b;请参阅comp.compilers.lcc获取更多

信息。)


请注意,符合标准的实现可能有扩展(包括

额外的库函数),前提是它们不会改变行为

of任何严格符合的程序,所以lcc-win32可能仍然符合

a C编译器。


-

Keith Thompson(The_Other_Keith ) ks***@mib.org < http://www.ghoti.net/~kst>

圣地亚哥超级计算机中心< *> < http://users.sdsc.edu/~kst>

我们必须做点什么。这是事情。因此,我们必须这样做。



In what sense is this "without leaving the framework of C"?

You don''t really *need* operator overloading; anything you can do with
it, you can do without it (with ordinary function calls).

Some languages support operator overloading: C++, Ada, the extended
C-like language supported by lcc-win32, and others. Standard C itself
does not. (And of course lcc-win32, as the name implies, is limited
to 32-bit Windows systems; see comp.compilers.lcc for more
information.)

Note that a conforming implementation may have extensions (including
additional library functions), provided they do not alter the behavior
of any strictly conforming program, so lcc-win32 may still qualify as
a C compiler.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.


这篇关于如何重新定义算术运算符。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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