2 double abs = input > 0 ? input:-1*input;
3 double lo = pow(2, value_length-2);
4 double up = pow(2, value_length-1);
6 while(abs < lo) {abs*=2;--p;}
7 while(abs >= up) {abs/=2;++p;}
9 value =
Integer(value_length, (
long long)(abs*(input > 0 ? 1: -1)), party);
20 inline string Float::reveal<string>(
int party)
const {
23 return to_string(val*pow(2.0, exp));
27 inline double Float::reveal<double>(
int party)
const {
30 return val*pow(2.0, exp);
34 string res = reveal<string>(
party);
53 for(
int i = bits_to_shift.size()-1; i>0; --i)
54 bits_to_shift[i] = value_before_normalize[i] ^ value_before_normalize[i-1];
55 bits_to_shift[0] =
true;
58 value_before_normalize = value_before_normalize << shift_amount;
61 value = value_before_normalize;
71 Bit to_swap = diff[diff.
size()-1];
75 swap(to_swap, v1, v2);
86 return (*
this) + (-rhs);
102 Bit extra_move = v1[v1.
size()-1] == v1[v1.
size()-2];
103 v1 = v1.
If(extra_move, v1 << 1);
119 for(
int i = 0; i <= rhs.
size(); ++i) {
123 res[rhs.
size()-i] = !diff[diff.
size()-1];
124 tmp = tmp.
If(!diff[diff.
size()-1], diff);
125 for(
int j = 0; j < tmp.
size(); ++j)
126 i1[rhs.
size()+j-i] = tmp[j];
167 Float tmp = (*this) - rhs;
Float operator &(const Float &rhs) const
Float operator/(const Float &rhs) const
Definition: float.hpp:133
Float abs() const
Definition: float.hpp:44
Float operator+(const Float &rhs) const
Definition: float.hpp:67
Bit equal(const Float &rhs) const
Definition: float.hpp:170
Float operator-() const
Definition: float.hpp:89
Integer & resize(int length, bool signed_extend=true)
Definition: integer.hpp:215
Float If(const Bit &select, const Float &d)
Definition: float.hpp:12
#define PUBLIC
Definition: utils.h:14
Integer value
Definition: float.h:11
Integer abs() const
Definition: integer.hpp:208
Float operator^(const Float &rhs) const
Definition: float.hpp:152
string detail(int party) const
Definition: float.hpp:33
Float(Float &&in)
Definition: float.h:13
int size() const
Definition: float.hpp:40
int size() const
Definition: integer.hpp:203
void swap(const Bit &swap, T &o1, T &o2)
Definition: swappable.h:18
Integer divide_frac(const Integer &lhs, const Integer &rhs)
Definition: float.hpp:114
Bit greater(const Float &rhs) const
Definition: float.hpp:166
Integer leading_zeros() const
Definition: integer.hpp:357
void normalize(int value_length, int to_add_to_expnt)
Definition: float.hpp:50
Integer expnt
Definition: float.h:12
Float operator|(const Float &rhs) const
Definition: float.hpp:145
Float operator*(const Float &rhs) const
Definition: float.hpp:95
O reveal(int party=PUBLIC) const
T If(const Bit &sel, const T &rhs) const
Definition: swappable.h:8