Description
Construction of an ac_int from a double is supported through the ac_int<W, S>(double) constructor. By default, this conversion uses the AC_TRN quantization mode, which truncates values toward negative infinity.
Consider the following example:
#include "ac_int.h"
#include <iostream>
int main() {
// Very small negative fractional value
double d = -8.90029437303091e-308;
ac_int<52, true> result(d);
std::cout << result << std::endl;
return 0;
}
In this example, a very small negative double value is converted to an ac_int<52, true> using the default AC_TRN quantization behavior.
Expected behavior
print -1
Actual behavior
prints 0
Possible fix
Suggested Fix Apply floor() at the beginning of the ac_int(double) constructor to ensure that the conversion follows the default AC_TRN quantization behavior (truncation toward negative infinity).
Steps to reproduce
Copy the attached code and run it
Context
This behaviour is not compliant with the AC Datatypes Standard 2025.4 specification.
Additional information
No response
Description
Construction of an ac_int from a double is supported through the ac_int<W, S>(double) constructor. By default, this conversion uses the AC_TRN quantization mode, which truncates values toward negative infinity.
Consider the following example:
In this example, a very small negative double value is converted to an ac_int<52, true> using the default AC_TRN quantization behavior.
Expected behavior
print -1
Actual behavior
prints 0
Possible fix
Suggested Fix Apply
floor()at the beginning of theac_int(double)constructor to ensure that the conversion follows the defaultAC_TRNquantization behavior (truncation toward negative infinity).Steps to reproduce
Copy the attached code and run it
Context
This behaviour is not compliant with the AC Datatypes Standard 2025.4 specification.
Additional information
No response