bignum.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* bignum.h-arbitrary precision integers
  2. Copyright (C) 1987-2015 Free Software Foundation, Inc.
  3. This file is part of GAS, the GNU Assembler.
  4. GAS is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3, or (at your option)
  7. any later version.
  8. GAS is distributed in the hope that it will be useful, but WITHOUT
  9. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  11. License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GAS; see the file COPYING. If not, write to
  14. the Free Software Foundation, 51 Franklin Street - Fifth Floor,
  15. Boston, MA 02110-1301, USA. */
  16. /***********************************************************************\
  17. * *
  18. * Arbitrary-precision integer arithmetic. *
  19. * For speed, we work in groups of bits, even though this *
  20. * complicates algorithms. *
  21. * Each group of bits is called a 'littlenum'. *
  22. * A bunch of littlenums representing a (possibly large) *
  23. * integer is called a 'bignum'. *
  24. * Bignums are >= 0. *
  25. * *
  26. \***********************************************************************/
  27. #define LITTLENUM_NUMBER_OF_BITS (16)
  28. #define LITTLENUM_RADIX (1 << LITTLENUM_NUMBER_OF_BITS)
  29. #define LITTLENUM_MASK (0xFFFF)
  30. #define LITTLENUM_SHIFT (1)
  31. #define CHARS_PER_LITTLENUM (1 << LITTLENUM_SHIFT)
  32. #ifndef BITS_PER_CHAR
  33. #define BITS_PER_CHAR (8)
  34. #endif
  35. typedef unsigned short LITTLENUM_TYPE;