test: recip.c File Reference

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# recip.c File Reference

`#include <stdio.h>`

Go to the source code of this file.

## Classes

struct | _large_integer

## Typedefs

typedef _large_integer | large_integer

## Functions

void | main (int argc, argv)

## Variables

long | Divisors [] = {10, 10000, 10000000, 86400000, 0}

## Typedef Documentation

typedef struct _large_integer large_integer

## Function Documentation

void main | ( | int | argc,
|  | argv |
| ) |

Definition at line 37 of file recip.c.

References Divisors, _large_integer::HighPart, Index, L, and _large_integer::LowPart.

    00040 {
    00041
    00042     large_integer Fraction;
    00043     long Index;
    00044     long NumberBits;
    00045     long Remainder;
    00046
    00047     long i;
    00048
    00049     //
    00050     // Compute first few reciprocols.
    00051     //
    00052
    00053     for (Index = Divisors[i = 0]; Index != 0L; Index = Divisors[++i]) {
    00054         NumberBits = 0L;
    00055         Remainder = 1L;
    00056         Fraction.LowPart = 0L;
    00057         Fraction.HighPart = 0L;
    00058         while (Fraction.HighPart >= 0L) {
    00059             NumberBits += 1L;
    00060             Fraction.HighPart <<= 1L;
    00061             if ((Fraction.LowPart & 0x80000000) != 0L) {
    00062                 Fraction.HighPart += 1L;
    00063             }
    00064             Fraction.LowPart <<= 1L;
    00065             Remainder <<= 1L;
    00066             if (Remainder >= Index) {
    00067                 Remainder -= Index;
    00068                 Fraction.LowPart |= 1L;
    00069             }
    00070         }
    00071         if (Remainder) {
    00072             if ((Fraction.LowPart == -1L) && (Fraction.HighPart == -1L)) {
    00073                 Fraction.LowPart = 0L;
    00074                 Fraction.HighPart = 0x80000000;
    00075                 NumberBits -= 1L;
    00076             } else {
    00077                 if (Fraction.LowPart == -1L) {
    00078                     Fraction.LowPart = 0L;
    00079                     Fraction.HighPart += 1L;
    00080                 } else {
    00081                     Fraction.LowPart += 1L;
    00082                 }
    00083             }
    00084         }
    00085
    00086         printf("Divisor %2ld,  Fraction %8lx, %8lx Shift  %ld\n", Index,
    00087                Fraction.HighPart, Fraction.LowPart, NumberBits - 64L);
    00088     }
    00089
    00090     return;
    00091 }

## Variable Documentation

long Divisors[] = {10, 10000, 10000000, 86400000, 0}

| Definition at line 34 of file recip.c. Referenced by main().