Index: ossp-pkg/ui64/ui64.c RCS File: /v/ossp/cvs/ossp-pkg/ui64/ui64.c,v rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/ui64/ui64.c,v' 2>/dev/null --- ui64.c 2002/04/28 13:22:49 1.1 +++ ui64.c 2002/04/28 18:58:01 1.2 @@ -37,6 +37,7 @@ #define UI64_DIGITS 8 /* 8*8 = 64 bit */ #define UIXX_T(n) struct { unsigned char x[n]; } +/* fill an ui64_t with a sequence of a particular digit */ #define ui64_fill(__x, __n) \ do { int __i; \ for (__i = 0; __i < UI64_DIGITS; __i++) \ @@ -77,7 +78,7 @@ } /* convert internal format into ISO-C "unsigned long"; - truncates if sizeof(unsigned long) is less than 8!) */ + truncates if sizeof(unsigned long) is less than UI64_DIGITS! */ unsigned long ui64_i2n(ui64_t x) { unsigned long n; @@ -159,6 +160,7 @@ return str; } +/* addition of two ui64_t */ ui64_t ui64_add(ui64_t x, ui64_t y, ui64_t *ov) { ui64_t z; @@ -176,6 +178,7 @@ return z; } +/* addition of an ui64_t and a single digit */ ui64_t ui64_addn(ui64_t x, int y, int *ov) { ui64_t z; @@ -191,6 +194,7 @@ return z; } +/* subtraction of two ui64_t */ ui64_t ui64_sub(ui64_t x, ui64_t y, ui64_t *ov) { ui64_t z; @@ -209,6 +213,7 @@ return z; } +/* subtraction of an ui64_t and a single digit */ ui64_t ui64_subn(ui64_t x, int y, int *ov) { ui64_t z; Index: ossp-pkg/ui64/ui64.h RCS File: /v/ossp/cvs/ossp-pkg/ui64/ui64.h,v rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/ui64/ui64.h,v' 2>/dev/null --- ui64.h 2002/04/28 13:22:49 1.1 +++ ui64.h 2002/04/28 18:58:01 1.2 @@ -37,7 +37,7 @@ unsigned char x[8]; /* x_0, ..., x_7 */ } ui64_t; -/* minimum/maximum values */ +/* particular values */ extern ui64_t ui64_zero (void); extern ui64_t ui64_max (void); Index: ossp-pkg/ui64/ui64.pod RCS File: /v/ossp/cvs/ossp-pkg/ui64/ui64.pod,v rcsdiff -q -kk '-r1.2' '-r1.3' -u '/v/ossp/cvs/ossp-pkg/ui64/ui64.pod,v' 2>/dev/null --- ui64.pod 2002/04/28 13:27:24 1.2 +++ ui64.pod 2002/04/28 18:58:01 1.3 @@ -40,19 +40,183 @@ =head1 SYNOPSIS -... +B, +B, +B, +B, +B, +B, +B, +B, +B, +B, +B, +B, +B, +B, +B, +B, +B, +B, +B, +B, +B, +B. =head1 DESCRIPTION -B is a ... +B is a small B library for portable 64-bit arithmetic. -=head2 APPLICATION PROGRAMMER INTERFACE (API) +=head1 APPLICATION PROGRAMMER INTERFACE (API) -=head1 EXAMPLE +=head2 Particular Values -=head1 SEE ALSO +API functions providing particular values: -B unsigned long long. +=over 4 + +=item ui64_t B(void); + +The value 0, expressed as an ui64_t. + +=item ui64_t B(void); + +The maximum value expressable as an ui64_t. + +=back + +=head2 Import & Export + +API functions providing value importing and exporting to and from native +B representations: + +=over 4 + +=item ui64_t B(unsigned long I); + +Import value from B C I. + +=item unsigned long B(ui64_t I); + +Export value of I to B C. This operation is not +less-less if the 64-bit value in I exceeds the B value +C. + +=item ui64_t B(const char *I, char **I, int I); + +Import value from C-terminated B string representation +starting at I. The representation can have leading whitespaces and +its (case-insensitive) digits (C<0>, ..., C<9>, C, ..., C) are +interpreted to base I. I has to be greater or equal 2 and +less than 36. If I is not C, it is set to the first character +after the imported value representation. + +=item char *B(ui64_t I, char *I, size_t I, int I); + +Export value of I to B string representation. The +representation consists of digits (C<0>, ..., C<9>, C, ..., C) and +form the value to base I. I has to be greater or equal 2 and +less than 36. The representation is stored into the buffer starting at +I and lasting I bytes. + +=back + +=head2 Arithmetical Operations + +API functions performing the standard arithmetical operations: + +=over 4 + +=item ui64_t B(ui64_t I, ui64_t I, ui64_t *I); + +Addition of I and I. +If I is not C, it receives the overflow value of +this operation (carry). + +=item ui64_t B(ui64_t I, int I, int *I); + +Same as B, but I and I are single digits to base 2^8. + +=item ui64_t B(ui64_t I, ui64_t I, ui64_t *I); + +Subtraction of I from I. +If I is not C, it receives the overflow value of +this operation (borrow). + +=item ui64_t B(ui64_t I, int I, int *I); + +Same as B, but I and I are single digits to base 2^8. + +=item ui64_t B(ui64_t I, ui64_t I, ui64_t *I); + +Multiplication of I and I. +If I is not C, it receives the overflow value of +this operation). + +=item ui64_t B(ui64_t I, int I, int *I); + +Same as B, but I and I are single digits to base 2^8. + +=item ui64_t B(ui64_t I, ui64_t I, ui64_t *I); + +Division of I by I. +If I is not C, it receives the overflow value of +this operation (remainder). + +=item ui64_t B(ui64_t I, int I, int *I); + +Same as B, but I and I are single digits to base 2^8. + +=back + +=head2 Bit Operations + +API functions performing the standard bit-wise operations: + +=over 4 + +=item ui64_t B(ui64_t I, ui64_t I); + +Bit-wise I operation between I and I. + +=item ui64_t B(ui64_t I, ui64_t I); + +Bit-wise I operation between I and I. + +=item ui64_t B(ui64_t I, ui64_t I); + +Bit-wise I operation between I and I. + +=item ui64_t B(ui64_t I); + +Bit-wise I operation of I. + +=item ui64_t B(ui64_t I, int I, ui64_t *I); + +Bit-wise I operation by I bits of I. +If I is not C, it contains the out-rotated bits. + +=item ui64_t B(ui64_t I, int I, ui64_t *I); + +Bit-wise I operation by I bits of I. +If I is not C, it contains the out-rotated bits. + +=back + +=head2 Other Operations + +=over 4 + +=item int B(ui64_t I); + +Number of digits (1-8) to base 2^8 in I. + +=item int B(ui64_t I, ui64_t I); + +Comparison of I and I values. Returns C<-1>, C<0> +or C<+1> if I is less/equal/greater than I. + +=back =head1 HISTORY