// Implementation.
-#include "cl_lfloat.h"
+#include "cln/lfloat.h"
#include "cl_LF_impl.h"
-#include "cl_integer.h"
+#include "cln/integer.h"
#include "cl_I.h"
#include "cl_DS.h"
#include "cl_F.h"
#include "cl_N.h"
+namespace cln {
+
const cl_LF cl_LF_I_div (const cl_LF& x, const cl_I& y)
{
// Method:
// Else divide the mantissa of x by the absolute value of y, then round.
if (TheLfloat(x)->expo == 0) {
if (zerop(y))
- cl_error_division_by_0();
+ throw division_by_0_exception();
else
return x;
}
var cl_signean sign = -(cl_signean)minusp(y); // Vorzeichen von y
var cl_I abs_y = (sign==0 ? y : -y);
- var uintL y_exp = integer_length(abs_y);
+ var uintC y_exp = integer_length(abs_y);
var uintC len = TheLfloat(x)->len;
#ifndef CL_LF_PEDANTIC
if (ceiling(y_exp,intDsize) > len)
return x / cl_I_to_LF(y,len);
#endif
- // x länger als y, direkt dividieren.
+ // x länger als y, direkt dividieren.
CL_ALLOCA_STACK;
var const uintD* y_MSDptr;
var uintC y_len;
var const uintD* y_LSDptr;
- I_to_NDS_nocopy(abs_y, y_MSDptr=,y_len=,y_LSDptr=,cl_false,); // NDS zu y bilden, y_len>0
+ I_to_NDS_nocopy(abs_y, y_MSDptr=,y_len=,y_LSDptr=,false,); // NDS zu y bilden, y_len>0
// y nicht zu einer NUDS normalisieren! (Damit ein Bit Spielraum ist.)
- // Zähler bilden: x * 2^(intDsize*y_len)
+ // Zähler bilden: x * 2^(intDsize*y_len)
var uintD* z_MSDptr;
- var uintL z_len;
+ var uintC z_len;
var uintD* z_LSDptr;
- z_len = (uintL)len + (uintL)y_len;
+ z_len = len + y_len;
num_stack_alloc(z_len, z_MSDptr=,z_LSDptr=);
{ var uintD* ptr = copy_loop_msp(arrayMSDptr(TheLfloat(x)->data,len),z_MSDptr,len); // len Digits
clear_loop_msp(ptr,y_len); // und y_len Null-Digits
}
msshrink(MSDptr);
}
- // Quotient MSDptr/len/.. ist nun normalisiert: höchstes Bit =1.
+ // Quotient MSDptr/len/.. ist nun normalisiert: höchstes Bit =1.
// exponent := exponent(x) - intDsize*y_len + shiftcount
- var uintL uexp = TheLfloat(x)->expo;
- var uintL dexp = intDsize*y_len - shiftcount; // >= 0 !
+ var uintE uexp = TheLfloat(x)->expo;
+ var uintE dexp = intDsize*y_len - shiftcount; // >= 0 !
if ((uexp < dexp) || ((uexp = uexp - dexp) < LF_exp_low)) {
if (underflow_allowed())
- { cl_error_floating_point_underflow(); }
+ { throw floating_point_underflow_exception(); }
else
{ return encode_LF0(len); }
}
else
// aufrunden
{ if ( inc_loop_lsp(MSDptr mspop len,len) )
- // Übertrag durchs Aufrunden
+ // Übertrag durchs Aufrunden
{ mspref(MSDptr,0) = bit(intDsize-1); // Mantisse := 10...0
// Exponenten incrementieren:
- if (++uexp == LF_exp_high+1) { cl_error_floating_point_overflow(); }
+ if (++uexp == LF_exp_high+1) { throw floating_point_overflow_exception(); }
} }
return encode_LFu(TheLfloat(x)->sign ^ sign, uexp, MSDptr, len);
}
// Bit complexity (N := max(length(x),length(y))): O(M(N)).
+} // namespace cln