??? 03/08/06 17:49 Read: times |
#111633 - C vs assembler, take 655321 Responding to: ???'s previous message |
Ian Bell said:
Apart from the evaluation version not supporting floating point, this is a particularly bad piece of C code
1. variable a is an unsigned short yet it is assigned the result of pow() which returns a float or possibly a double (I forget which) 2. pow() expects floating point arguments but it is passed an unsigned short - it should be cast to float. Yuk!!! Give me assembler any day. Give me a programmer who is aware of things. (Insert old saw about "C" and "rope to hang yourself" here.) Years of VHDL and Verilog makes me aware of needing to cast types and not allow the compiler to promote and truncate things. (Yes, I'm paranoid, and I blame Verilog.) 3. This about the most inefficient way I can think of to raise a variable to a power of 2!!! There's always programmer cleverness/laziness, which has nothing to do with the language ... -a |
Topic | Author | Date |
Keil C51 and Math | 01/01/70 00:00 | |
Eval version? | 01/01/70 00:00 | |
Not only but also | 01/01/70 00:00 | |
Come now | 01/01/70 00:00 | |
Come off it | 01/01/70 00:00 | |
poorly typed | 01/01/70 00:00 | |
Typing (sic) | 01/01/70 00:00 | |
Ian | 01/01/70 00:00 | |
What type? | 01/01/70 00:00 | |
any decent compiler will give you a warn | 01/01/70 00:00 | |
it depends | 01/01/70 00:00 | |
Get Promoted | 01/01/70 00:00 | |
Too much promotion! | 01/01/70 00:00 | |
Hells Bells | 01/01/70 00:00 | |
Ding Dong! | 01/01/70 00:00 | |
C vs assembler, take 655321 | 01/01/70 00:00 | |
anyone else will be a programmer in name | 01/01/70 00:00 | |
Programmer laziness | 01/01/70 00:00 | |
WebPage ? | 01/01/70 00:00 | |
Much different | 01/01/70 00:00 | |
And Also | 01/01/70 00:00 | |
Eh ? | 01/01/70 00:00 | |
C and C++ | 01/01/70 00:00 | |
Portable? | 01/01/70 00:00 | |
handle your microprocessor functi | 01/01/70 00:00 | |
Hm, | 01/01/70 00:00 | |
Keil does it | 01/01/70 00:00 | |
Floating point | 01/01/70 00:00 | |
Thanks, | 01/01/70 00:00 |