Real that uses Fast2Sum for addition
[ipdf/code.git] / src / tests / repr.cpp
1 #include "main.h"
2
3 #include <bitset>
4
5 using namespace std;
6
7
8
9 int main(int argc, char ** argv)
10 {
11         char buffer[BUFSIZ];
12         double input;
13         printf("Enter a double: ");
14         fgets(buffer, BUFSIZ, stdin);
15         sscanf(buffer, "%lf", &input);
16
17
18         float f = (float)(input);
19
20         unsigned long long i;
21         memcpy(&i, &f, 4);
22         bitset<32> b32(i);
23         memcpy(&i, &input, 8);
24         bitset<64> b64(i);
25
26         printf("\nAs float: %s\n", b32.to_string().c_str());
27         printf("\nAs double: %s\n", b64.to_string().c_str());
28         #ifdef REAL_BITSET
29                 Real r(input);
30                 printf("\nAs real: %s\n", r.repr.to_string().c_str());
31         #endif //REAL_BITSET
32         
33 }

UCC git Repository :: git.ucc.asn.au