home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mitsch75.zip / scheme-7_5_17-src.zip / scheme-7.5.17 / src / microcode / bignum.h < prev    next >
C/C++ Source or Header  |  1999-01-02  |  4KB  |  98 lines

  1. /* -*-C-*-
  2.  
  3. $Id: bignum.h,v 9.31 1999/01/02 06:11:34 cph Exp $
  4.  
  5. Copyright (c) 1989-1999 Massachusetts Institute of Technology
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or (at
  10. your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful, but
  13. WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15. General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21.  
  22. /* External Interface to Bignum Code */
  23.  
  24. /* The `unsigned long' type is used for the conversion procedures
  25.    `bignum_to_long' and `long_to_bignum'.  Older implementations of C
  26.    don't support this type; if you have such an implementation you can
  27.    disable these procedures using the following flag (alternatively
  28.    you could write alternate versions that don't require this type). */
  29. /* #define BIGNUM_NO_ULONG */
  30.  
  31. #include "ansidecl.h"
  32.  
  33. #ifdef MIT_SCHEME
  34.  
  35. typedef SCHEME_OBJECT bignum_type;
  36. #define BIGNUM_OUT_OF_BAND SHARP_F
  37.  
  38. #else
  39.  
  40. typedef long * bignum_type;
  41. #define BIGNUM_OUT_OF_BAND ((bignum_type) 0)
  42.  
  43. #endif
  44.  
  45. enum bignum_comparison
  46. {
  47.   bignum_comparison_equal, bignum_comparison_less, bignum_comparison_greater
  48. };
  49.  
  50. typedef PTR bignum_procedure_context;
  51. extern bignum_type EXFUN (bignum_make_zero, (void));
  52. extern bignum_type EXFUN (bignum_make_one, (int negative_p));
  53. extern int EXFUN (bignum_equal_p, (bignum_type, bignum_type));
  54. extern enum bignum_comparison EXFUN (bignum_test, (bignum_type));
  55. extern enum bignum_comparison EXFUN
  56.   (bignum_compare, (bignum_type, bignum_type));
  57. extern bignum_type EXFUN (bignum_add, (bignum_type, bignum_type));
  58. extern bignum_type EXFUN (bignum_subtract, (bignum_type, bignum_type));
  59. extern bignum_type EXFUN (bignum_negate, (bignum_type));
  60. extern bignum_type EXFUN (bignum_multiply, (bignum_type, bignum_type));
  61. extern int EXFUN
  62.   (bignum_divide, (bignum_type numerator,
  63.            bignum_type denominator,
  64.            bignum_type * quotient,
  65.            bignum_type * remainder));
  66. extern bignum_type EXFUN (bignum_quotient, (bignum_type, bignum_type));
  67. extern bignum_type EXFUN (bignum_remainder, (bignum_type, bignum_type));
  68. #ifndef BIGNUM_NO_ULONG
  69. extern bignum_type EXFUN (long_to_bignum, (long));
  70. extern bignum_type EXFUN (ulong_to_bignum, (unsigned long));
  71. extern long EXFUN (bignum_to_long, (bignum_type));
  72. extern unsigned long EXFUN (bignum_to_ulong, (bignum_type));
  73. #endif /* not BIGNUM_NO_ULONG */
  74. extern bignum_type EXFUN (double_to_bignum, (double));
  75. extern double EXFUN (bignum_to_double, (bignum_type));
  76. extern int EXFUN
  77.   (bignum_fits_in_word_p, (bignum_type,
  78.                long word_length,
  79.                int twos_complement_p));
  80. extern bignum_type EXFUN (bignum_length_in_bits, (bignum_type));
  81. extern bignum_type EXFUN (bignum_length_upper_limit, (void));
  82. extern bignum_type EXFUN (bignum_shift_left, (bignum_type, unsigned long));
  83. extern bignum_type EXFUN
  84.   (unsigned_long_to_shifted_bignum, (unsigned long, unsigned long, int));
  85. extern bignum_type EXFUN
  86.   (digit_stream_to_bignum,
  87.    (unsigned int n_digits,
  88.     unsigned int EXFUN ((*producer), (bignum_procedure_context)),
  89.     bignum_procedure_context context,
  90.     unsigned int radix,
  91.     int negative_p));
  92. extern void EXFUN
  93.   (bignum_to_digit_stream,
  94.    (bignum_type, unsigned int radix,
  95.     void EXFUN ((*consumer), (bignum_procedure_context, long)),
  96.     bignum_procedure_context context));
  97. extern long EXFUN (bignum_max_digit_stream_radix, (void));
  98.