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)
|