Main Page | Data Structures | File List | Data Fields | Globals

int_numbers.c

Go to the documentation of this file.
00001 
00009 #include<stdio.h>
00010 #include"numbers.h"
00011 
00017 static number addInt(const number x,const number y);
00023 static number multInt(const number x,const number y);
00027 static number getUnitInt();
00031 static number getZeroInt();
00035 static void displayInt(const number x);
00036 
00037 
00042 number getIntNumber(const int n){
00043   number t ={ INT_NUMBER, 
00044               {n},
00045               &addInt,
00046               &multInt,
00047               &getUnitInt,
00048               &getZeroInt,
00049               &displayInt};
00050   return t;
00051 }
00052 
00053 static number addInt(const number a, const number b){
00054   number c=a;
00055   if (a.type!=INT_NUMBER || b.type!=INT_NUMBER){
00056     return error;
00057   }
00058   c.val.intval=a.val.intval+b.val.intval;
00059   return c;
00060 }
00061 
00062 static number multInt(const number a, const number b){
00063   number c=a;
00064   if (a.type!=INT_NUMBER || b.type!=INT_NUMBER){
00065     return error;
00066   }
00067   c.val.intval=a.val.intval*b.val.intval;
00068   return c;
00069 }
00070 
00071 static number getUnitInt(){
00072   return getIntNumber(1);
00073 }
00074 
00075 static number getZeroInt(){
00076     return getIntNumber(0);
00077 }
00078 
00079 void displayInt(const number x){
00080   printf("%d",x.val.intval);
00081 }
00082 

Generated on Thu Dec 18 16:01:23 2008 for Numbers by  doxygen 1.3.9.1