TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: CAMERON CLARK
from: ERIK WARMELINK
date: 1997-07-15 03:01:00
subject: Re: Signs of numbers

Cameron, 14 Jul you wrote to Bob Stout:
BS> 1.  It only works on two's-complement machines. The C and C++ language
BS>     standards have been written to allow implementation on machines using
BS>     other numeric representations.
 CC>     The implementation of the language on a specific machine
 CC>     should take care of the work for you.
You should read the standard before demanding a certain implementation.
 CC> Saying  "8000" bit for and integer assumes that an int is 32 
 CC> bits. This is not the case for all compilers. BC4.5 is an 
 CC> example that limits data types depending upon the target type 
 CC> (dos/win16/win32). 
That's another good reason to write
   negative = x < 0;
 CC>     It would be stupid to want to test the sign of an
 CC> unsigned variable. 
Heh? An unsigned can be zero or positive, enough reason to test the sign.
 CC>     For readability, I would have used if testing for each
 CC> case. Ors and Ands are for speed.
If ``x && value'' would be faster than ``x < 0'' even an average compiler 
would produce your code if someone writes ``x < 0''. It is much harder to 
optimize obfuscated code like ``x & value'', if that happens to be equivalent 
to ``x < 0''.
Bye,
 Erik 
---
---------------
* Origin: WarmelinkE@vertis.nl (2:282/1.60)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.