Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Smallest Integer Greater than Very Large Number
- unsigned long smallestLargerInteger(unsigned long startNum) {
- return startNum +1;
- }
- #define __HALF_MAX_SIGNED(type) ((type)1 << (sizeof(type)*8-2))
- #define __MAX_SIGNED(type) (__HALF_MAX_SIGNED(type) - 1 + __HALF_MAX_SIGNED(type))
- #define __MIN_SIGNED(type) (-1 - __MAX_SIGNED(type))
- #define __MIN(type) ((type)-1 < 1?__MIN_SIGNED(type):(type)0)
- #define __MAX(type) ((type)~__MIN(type))
- unsigned long smallestLargerInteger(unsigned long startNum) {
- if(__MAX(long) == startNum) {
- // handle overflow error messaging here
- }
- return startNum +1;
- }
Add Comment
Please, Sign In to add comment