next up previous contents
Next: Fixed Precision Integers Up: General Field Elements Previous: Header Files

Usage Examples

  #include "field.h"

  int
  main(int argc, char** argv)
  {
    Field_element fe1 = 5;            // Creates a SmallInt type with value 5 
    Field_element fe2 = 10.0          // Creates a Float type with value 10.0
    Field_element result = fe1 + fe2; // Add 5 and 10.0
    cout << result;                   // Prints result to standard output. 
    Field_element fe4 = integer(4);   // Creates a BigInt type with value 4 
    Field_element result = fe4 / fe1; // Operand with different types - 
                                      // allowed for some combinations
    cout << result;                   // Prints result to standard output. 
    if (is_zero(result))              // Test for zero
      cout << "Result is 0\n"; 
  }

1.0



Ashu Rege
Fri May 9 17:57:21 PDT 1997