Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- struct Undef {
- public:
- Undef(){
- width++; //set type width. This is how much the address shifts using ++ --
- }
- bool* addr=0x0; //store data in form of address
- bool* width=0x0;
- void inc(){
- addr++;
- }
- void dec(){
- addr--;
- }
- bool* operator()(){
- return addr;
- }
- };
- class Constants{
- public:
- Constants(){ //set constants
- placeholder.addr--;
- inf=placeholder.addr;
- }
- Undef placeholder;
- bool* zero=0x0;
- bool* inf=0x0;
- };
- class UndefMngr{
- public:
- Constants vof;
- Undef add(Undef num){
- Undef inc=num;
- while(inc.addr>vof.zero){
- num.inc();
- inc.dec();
- }
- return num;
- }
- Undef sq(Undef num){ //doubling
- Undef inc=num;
- while((void*)inc.addr>vof.zero){
- num=add(num);
- inc.dec();
- }
- return num;
- }
- Undef sq16(Undef num){ //doubling double
- Undef inc=num;
- while((void*)inc.addr>vof.zero){
- num=sq(num);
- inc.dec();
- }
- return num;
- }
- Undef sub(Undef value, Undef subtractor){ //subtract
- Undef dec=subtractor;
- while((void*)dec.addr>vof.zero){
- value.dec();
- dec.dec();
- }
- return value;
- }
- };
- int main(){
- UndefMngr math;
- Undef num;
- printf("Zero %p\n", (void*)math.vof.zero );
- printf("Infinity %p\n", (void*)math.vof.inf );
- printf("width %p\n", (void*)num.width );
- num.inc();
- printf("num+1 %p\n", (void*)num.addr );
- num=math.sq(num);
- printf("num doubled %p\n", (void*)num.addr );
- Undef num2 = num;
- num=math.sq16(num);
- printf("num doubled double %p\n", (void*)num.addr );
- Undef result = math.sub(num,num2);
- printf("subtracted %p from %p resulting in %p\n", (void*)num.addr, (void*)num2.addr, (void*)result.addr );
- return 0;
- }
- /*Output
- Zero (nil)
- Infinity 0xffffffffffffffff
- width 0x1
- num+1 0x1
- num doubled 0x2
- num doubled double 0x800
- subtracted 0x800 from 0x2 resulting in 0x7fe
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement