You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
NumberToString fails if:
NumberFormat is set to Scientific or Engineering, the exponent is negative, the requested precision is < as the original precision and the number of digits in PNUMBER is >= as the requested precision.
RatToString calls NumberToString and also fails.
Steps To Reproduce
#include <iostream>
#include <ratpak.h>
constexpr auto RAT_RADIX = 10U;
constexpr auto RAT_PRECISION = 32;
constexpr auto RAT_REDUCED_PRECISION = 16;
int main()
{
ChangeConstants(RAT_RADIX, RAT_PRECISION);
PNUMBER n = StringToNumber(std::wstring_view(L"1.456789234243564534e-20"), RAT_RADIX, RAT_PRECISION);
std::wcout << NumberToString(n, NumberFormat::Scientific, RAT_RADIX, RAT_REDUCED_PRECISION) << std::endl; // not ok, expected 1.456789234243565e-20
destroynum(n);
}
Output:
0.e-20
Expected behavior
Instead of 0.e-20 the expected output should be 1.456789234243565e-20
The function works as expected if the exponent is positive.
Additional context
I use ratpak in a (hardware) calculator project, The precision of the calculations and the internal registers is set to 32 but I only display 14 digits, This is why I'm reducing the precision in the conversion.
Ratpak is great - small, and efficient enough to even run on a microcontroller. I think the library just needs a little TLC...
Requested Assignment
I'm just reporting this problem. I don't want to fix it.
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
NumberToString fails if:
NumberFormat is set to Scientific or Engineering, the exponent is negative, the requested precision is < as the original precision and the number of digits in PNUMBER is >= as the requested precision.
RatToString calls NumberToString and also fails.
Steps To Reproduce
Output:
Expected behavior
Instead of 0.e-20 the expected output should be 1.456789234243565e-20
The function works as expected if the exponent is positive.
Additional context
I use ratpak in a (hardware) calculator project, The precision of the calculations and the internal registers is set to 32 but I only display 14 digits, This is why I'm reducing the precision in the conversion.
Ratpak is great - small, and efficient enough to even run on a microcontroller. I think the library just needs a little TLC...
Requested Assignment
I'm just reporting this problem. I don't want to fix it.
The text was updated successfully, but these errors were encountered: