Guest User

Untitled

a guest
Aug 17th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. Smallest Integer Greater than Very Large Number
  2. unsigned long smallestLargerInteger(unsigned long startNum) {
  3. return startNum +1;
  4. }
  5.  
  6. #define __HALF_MAX_SIGNED(type) ((type)1 << (sizeof(type)*8-2))
  7. #define __MAX_SIGNED(type) (__HALF_MAX_SIGNED(type) - 1 + __HALF_MAX_SIGNED(type))
  8. #define __MIN_SIGNED(type) (-1 - __MAX_SIGNED(type))
  9.  
  10. #define __MIN(type) ((type)-1 < 1?__MIN_SIGNED(type):(type)0)
  11. #define __MAX(type) ((type)~__MIN(type))
  12.  
  13. unsigned long smallestLargerInteger(unsigned long startNum) {
  14. if(__MAX(long) == startNum) {
  15. // handle overflow error messaging here
  16. }
  17.  
  18. return startNum +1;
  19. }
Add Comment
Please, Sign In to add comment