}
assert(exp_val >= 0 && "floating point value not integral before fc_flt2int() call");
- shift = a->desc.mantissa_size - exp_val + 2;
+ shift = exp_val - a->desc.mantissa_size - 2;
- sc_shrI(_mant(a), shift, 64, 0, result);
+ if (shift > 0) {
+ sc_shlI(_mant(a), shift, 64, 0, result);
+ } else {
+ sc_shrI(_mant(a), -shift, 64, 0, result);
+ }
/* check for overflow */
highest = sc_get_highest_set_bit(result);
}
-void sc_shl(const void *val1, const void *val2, int radius, int sign, void *buffer) {
- long offset = sc_val_to_long(val2);
-
+void sc_shlI(const void *val1, long offset, int radius, int sign, void *buffer) {
carry_flag = 0;
DEBUGPRINTF_COMPUTATION(("%s << %ld ", sc_print_hex(value1), offset));
}
}
+void sc_shl(const void *val1, const void *val2, int radius, int sign, void *buffer) {
+ long offset = sc_val_to_long(val2);
+
+ sc_shlI(val1, offset, radius, sign, buffer);
+}
+
void sc_shrI(const void *val1, long offset, int radius, int sign, void *buffer) {
carry_flag = 0;
*/
void sc_divmod(const void *value1, const void *value2, void *div_buffer, void *mod_buffer);
+/**
+ * buffer = value1 << offset
+ */
+void sc_shlI(const void *val1, long offset, int radius, int sign, void *buffer);
+
/**
* buffer = value1 << value2
*/