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. 12 2109
Le 29-11-2005, Raghu <ra************ ***@in.bosch.co m> a écrit*: 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.
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 : 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.
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. http://www.cs.virinia.edu/~lcc-win32
jacob navia <ja***@jacob.re mcomp.fr> writes: Raghu a écrit : 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] 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.
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_Keit h) 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.
Keith Thompson a écrit : You don't really *need* operator overloading; anything you can do with it, you can do without it (with ordinary function calls).
This is of course true.
It is just a matter of measure.
Consider this:
qfloat a;
qfloat q = (sqrt(a+1)/sqrt(a-1))*(cos(a+1)/cos(a-1));
compared with:
tmp1 = qadd(a,1);
tmp2 = sqrtq(tmp1);
tmp3 = qsub(a,1);
tmp4 = sqrt(tmp3);
tmp5 = qdiv(tmp1,tmp3) ;
tmp6 = cosq(tmp1);
tmp7 = cosq(tmp3);
tmp8 = qdiv(tmp6,tmp7) ;
result = qmul(tmp8,tmp5) ;
This does the *same* stuff but which expression would
you prefer???
And above all, which expression would you like to MAINTAIN?
Of course operator overloading is just "syntactic sugar".
But sugar is an essential component of meals !!!
Of course you can abuse it, (as you can abuse *real* sugar!)
but for *many* applications is the only way to go!
Being able to define new types of numbers is one of them.
Otherwise, the C syntax is totally awkward.
jacob
jacob navia wrote
(in article <43************ ***********@new s.wanadoo.fr>): I am afraid to start a new flame war here,
Actually, you seem to revel in it.
but if you accept to use *non-standard* C,
(thereby leaving the 'framework of C')
the lcc-win32 compiler allows you to do operator overloading without leaving the framework of C.
Incorrect. You are using extensions so non-standard that they
ONLY work on a single compiler, for a single operating system.
Even the folks that use gcc extensions are far better off than
that, nevermind the POSIX crowd, which has it golden in
comparison.
... but it is compatible with the standard.
No, it isn't. Try compiling it on a compiler from anyone else.
So much for that theory.
--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw
On Tue, 29 Nov 2005 11:31:19 +0100, jacob navia
<ja***@jacob.re mcomp.fr> wrote in comp.lang.c: Raghu a écrit : 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. 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.
http://www.cs.virinia.edu/~lcc-win32
Jacob, as much as I admire lcc-win32, I was not aware that you had a
cross compiler that output PowerPC executables.
--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++ http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
jacob navia <ja***@jacob.re mcomp.fr> wrote: Consider this: qfloat a; qfloat q = (sqrt(a+1)/sqrt(a-1))*(cos(a+1)/cos(a-1));
compared with:
This does the *same* stuff but which expression would you prefer???
Neither. I would prefer not to use superfluous not-C. Even more than
that I would prefer not-C not to be discussed here.
Richard
Jack Klein wrote: On Tue, 29 Nov 2005 11:31:19 +0100, jacob navia <ja***@jacob.re mcomp.fr> wrote in comp.lang.c:
Raghu a écrit :
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.
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.
http://www.cs.virinia.edu/~lcc-win32
Jacob, as much as I admire lcc-win32, I was not aware that you had a cross compiler that output PowerPC executables.
AAAAArgh!!
You are right. My fault.
jacob
In article <43************ *@news.xs4all.n l>,
Richard Bos <rl*@hoekstra-uitgeverij.nl> wrote: jacob navia <ja***@jacob.re mcomp.fr> wrote:
Consider this: qfloat a; qfloat q = (sqrt(a+1)/sqrt(a-1))*(cos(a+1)/cos(a-1));
compared with:
This does the *same* stuff but which expression would you prefer???
Neither. I would prefer not to use superfluous not-C. Even more than that I would prefer not-C not to be discussed here.
Richard
Because we all know how dangerous thoughts and words can be to an
established order. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Christian Brechbühler |
last post by:
The template std::valarray behaves pretty much like a mathematical
vector. Arithmetic operators apply elementwise. Now I'd like to extend
this to a user-defined type, e.g., complex.
Multiplying a double by a complex number gives a complex number. Now I
would like to multiply a valarray of doubles by a complex number and get
a valarray of complex numbers. Of course, a C++ compiler won't jump to
that conclusion; I need to define...
|
by: Amy |
last post by:
Hello,
We are developing C++ appplications for PDAs where memory is limited,
so we want to do memory management by ourselves --- pre-allocated a big
chunk and overwrite new and delete to call our APIs.
The tricky thing simply redefine operator new and delete because the
OS(PDA platform OS)library we need to link with in our application also
redefined operator new/delete for some purpose. Simply redefine
new/delete as following won't...
|
by: Lionel B |
last post by:
Greetings,
I am trying to implement "element-wise" arithmetic operators for a class
along the following lines (this is a simplified example):
// ----- BEGIN CODE -----
struct X
{
int a,b;
|
by: Mehta Shailendrakumar |
last post by:
Hello,
Can anyone suggest me operator to perform arithmetic shift in C?
May it be for a perticular compiler.
Thank you in advance.
Regards,
Shailendra
|
by: Satpreet |
last post by:
I'm looking to simulate the behavior of a digital hardware arithmetic
block in a C/C++ program.
I was just wondering if there are any libraries (with datatypes and
overloaded operators etc.) available for arithmetic operations on
Fixed/Block-Floating Point variables ??
Alternatively could anyone throw me a pointer to sample code if
available on the net...
| |
by: extrudedaluminiu |
last post by:
Hi,
Is there any group in the manner of the C++ Boost group that works on
the evolution of the C language? Or is there any group that performs an
equivalent function?
Thanks,
-vs
|
by: Thomas Kreuzer |
last post by:
Hello everyone,
I have a question regarding how to interpret a string.
Basically I want to write a little calculator, I will type something
like "12+69*12-44/2" and then want my program to compute it into the
result :)
I experimented a bit with strtok and the like, but I think I am not sure
how I should approach this problem. The problem being the priorities of
|
by: sarathy |
last post by:
Hi,
What is integer promotion? How is it different from
arithmetic conversion?
Regards,
Sarathy
|
by: tommyng |
last post by:
Hi,
I couldn't find any information/examples on how to redefine/overload the math operators in PHP. Is this even possible?
Thanks,
Tommy
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |