Bigdigits - $Id bigdigits.h $ SHORT COPYRIGHT NOTICE This source code is part of the BigDigits multiple-precision arithmetic library Version 2.2

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
/* $Id: bigdigits.h $ */ / /******************** SHORT COPYRIGHT NOTICE************************** This source code is part of the BigDigits multiple-precision arithmetic library Version 2.2 originally written by David Ireland, copyright (c) 2001-8 D.I. Management Services Pty Limited, all rights reserved. It is provided "as is" with no warranties. You may use this software under the terms of the full copyright notice "bigdigitsCopyright.txt" that should have been included with this library or can be obtained from <www.di-mgt.com.au/bigdigits.html>. This notice must always be retained in any copy. ******************* END OF COPYRIGHT NOTICE***************************/ /* Last updated: $Date: 2008-07-31 12:54:00 $ $Revision: 2.2.0 $ $Author: dai $ */ * /* Interface to BigDigits "mp" functions */ / #ifndef BIGDIGITS_H_ #define BIGDIGITS_H_ 1 # #include "bigdtypes.h" # /**** USER CONFIGURABLE SECTION ****/ / /* Define type and size of DIGIT */ / /* [v2.1] Changed to use C99 exact-width types so it will compile with 64-bit compilers. */ /* [v2.2] Put macros for exact-width types in separate file "bigdtypes.h" */ / typedef uint32_t DIGIT_T; typedef uint16_t HALF_DIGIT_T; t /* Sizes to match */ #define MAX_DIGIT 0xffffffffUL #define MAX_HALF_DIGIT 0xffffUL /* NB 'L' */ #define BITS_PER_DIGIT 32 #define HIBITMASK 0x80000000UL # /* [v2.2] added option to avoid allocating temp storage and use fixed automatic arrays instead. Define NO_ALLOCS to invoke this. Only applicable to mp functions. Do not use with bd. */ /* Specifiy the maximum number of digits allowed in a temp mp array -- ignored unless NO_ALLOCS is defined */ #ifdef NO_ALLOCS #define MAX_FIXED_DIGITS (8192 / BITS_PER_DIGIT) #endif # /**** END OF USER CONFIGURABLE SECTION ****/ / #define BITS_PER_HALF_DIGIT (BITS_PER_DIGIT / 2) #define BYTES_PER_DIGIT (BITS_PER_DIGIT / 8) #
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
/* Useful macros */ #define TOHIGH(x) ((DIGIT_T)((x) << BITS_PER_HALF_DIGIT)) # #define ISEVEN(x) (!ISODD(x)) # # #define mpNEXTBITMASK(mask, n) do{if(mask==1) {mask=HIBITMASK;n--;}else{mask>>=1;}}while(0) { #ifdef __cplusplus extern "C" { #endif # volatile char *copyright_notice(void); /* Forces linker to include copyright notice in executable */ / /* / * Multiple precision calculations * Using known, equal ndigits * except where noted */ * /*************************/ /* ARITHMETIC OPERATIONS */ /*************************/ / DIGIT_T mpAdd(DIGIT_T w[], const DIGIT_T u[], const DIGIT_T v[], size_t ndigits); /* Computes w = u + v, returns carry */ / DIGIT_T mpSubtract(DIGIT_T w[], const DIGIT_T u[], const DIGIT_T v[], size_t ndigits); /* Computes w = u - v, returns borrow */
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/26/2010 for the course CMPS 109 taught by Professor Bailey,d during the Spring '08 term at University of California, Santa Cruz.

Page1 / 6

Bigdigits - $Id bigdigits.h $ SHORT COPYRIGHT NOTICE This source code is part of the BigDigits multiple-precision arithmetic library Version 2.2

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online