Commit 743119ad authored by Cerlane Leong's avatar Cerlane Leong 💬

Python and CPP housekeeping: To ensure both lib have similar function names...

Python and CPP housekeeping: To ensure both lib have similar function names for conversion to Integer
parent 062cfe3c
......@@ -1265,10 +1265,13 @@ class posit8:
a = posit32(0)
a.v = _softposit.p8_to_p32(self.v)
return a
def toInt(self):
def toRInt(self):
return _softposit.p8_to_i64(self.v)
def toInt(self):
return _softposit.p8_int(self.v)
def rint(self):
return _softposit.p8_roundToInt(self.v)
self.v = _softposit.p8_roundToInt(self.v)
return self
def sqrt(self):
self.v = _softposit.p8_sqrt(self.v)
return self
......@@ -1553,10 +1556,13 @@ class posit16:
a = posit32(0)
a.v = _softposit.p16_to_p32(self.v)
return a
def toInt(self):
def toRInt(self):
return _softposit.p16_to_i64(self.v)
def toInt(self):
return _softposit.p16_int(self.v)
def rint(self):
return _softposit.p16_roundToInt(self.v)
self.v = _softposit.p16_roundToInt(self.v)
return self
def sqrt(self):
self.v = _softposit.p16_sqrt(self.v)
return self
......@@ -1842,10 +1848,13 @@ class posit32:
a = posit16(0)
a.v = _softposit.p32_to_p16(self.v)
return a
def toInt(self):
def toRInt(self):
return _softposit.p32_to_i64(self.v)
def toInt(self):
return _softposit.p32_int(self.v)
def rint(self):
return _softposit.p32_roundToInt(self.v)
self.v = _softposit.p32_roundToInt(self.v)
return self
def sqrt(self):
self.v = _softposit.p32_sqrt(self.v)
return self
......
......@@ -212,10 +212,13 @@ class posit8:
a = posit32(0)
a.v = _softposit.p8_to_p32(self.v)
return a
def toInt(self):
def toRInt(self):
return _softposit.p8_to_i64(self.v)
def toInt(self):
return _softposit.p8_int(self.v)
def rint(self):
return _softposit.p8_roundToInt(self.v)
self.v = _softposit.p8_roundToInt(self.v)
return self
def sqrt(self):
self.v = _softposit.p8_sqrt(self.v)
return self
......@@ -500,10 +503,13 @@ class posit16:
a = posit32(0)
a.v = _softposit.p16_to_p32(self.v)
return a
def toInt(self):
def toRInt(self):
return _softposit.p16_to_i64(self.v)
def toInt(self):
return _softposit.p16_int(self.v)
def rint(self):
return _softposit.p16_roundToInt(self.v)
self.v = _softposit.p16_roundToInt(self.v)
return self
def sqrt(self):
self.v = _softposit.p16_sqrt(self.v)
return self
......@@ -789,10 +795,13 @@ class posit32:
a = posit16(0)
a.v = _softposit.p32_to_p16(self.v)
return a
def toInt(self):
def toRInt(self):
return _softposit.p32_to_i64(self.v)
def toInt(self):
return _softposit.p32_int(self.v)
def rint(self):
return _softposit.p32_roundToInt(self.v)
self.v = _softposit.p32_roundToInt(self.v)
return self
def sqrt(self):
self.v = _softposit.p32_sqrt(self.v)
return self
......
......@@ -242,10 +242,14 @@ struct posit8{
return convertP8ToDouble(castP8(value));
}
long long int toInteger()const{
long long int toInt()const{
return p8_int(castP8(value));
}
long long int toRInt()const{
return p8_to_i64(castP8(value));
}
posit8& fma(posit8 a, posit8 b){ // += (a*b)
value = castUI(p8_mulAdd(castP8(a.value), castP8(b.value), castP8(value)));
return *this;
......@@ -470,10 +474,15 @@ struct posit16{
return convertP16ToDouble(castP16(value));
}
long long int toInteger()const{
long long int toInt()const{
return p16_int(castP16(value));
}
long long int toRInt()const{
return p16_to_i64(castP16(value));
}
posit16& fma(posit16 a, posit16 b){ // += (a*b)
value = castUI(p16_mulAdd(castP16(a.value), castP16(b.value), castP16(value)));
return *this;
......@@ -698,8 +707,12 @@ struct posit32{
return convertP32ToDouble(castP32(value));
}
long long int toInteger()const{
return p32_int(castP32(value));;
long long int toInt()const{
return p32_int(castP32(value));
}
long long int toRInt()const{
return p32_to_i64(castP32(value));
}
posit32& fma(posit32 a, posit32 b){ // += (a*b)
......@@ -849,6 +862,7 @@ struct quire32{
};
inline posit8 operator+(int a, posit8 b){
b.value = castUI(p8_add(i32_to_p8(a), castP8(b.value)));
return b;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment