-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Foreign.getInstance().longDoubleFromString returns garbage #60
Comments
The problem is, that the POSIX strtold uses the current locale to convert a string to long double, whereas BigDecimal.toEngeneeringString does not.
All other issues I saw I will file as separate issue. |
Sorry, this is a duplicate of #51 |
Fixed this in https://github.com/aploese/jffi/tree/fix-mips (hotfix) currently it creates a new locale "C" for every call. |
Avoid jnr/jffi#60 1) returnDefaultF128HighPrecision(com.kenai.jffi.NumberTest) java.lang.AssertionError Package-Manager: Portage-3.0.28, Repoman-3.0.3 Signed-off-by: Volkmar W. Pogatzki <[email protected]>
Avoid jnr/jffi#60 1) returnDefaultF128HighPrecision(com.kenai.jffi.NumberTest) java.lang.AssertionError Package-Manager: Portage-3.0.28, Repoman-3.0.3 Signed-off-by: Volkmar W. Pogatzki <[email protected]> Closes: #22916 Signed-off-by: Miroslav Šulc <[email protected]>
The failing of NumberTest.returnDefaultF128HighPrecision is buried here.
To reveal the reason, add the following test case to ForeignTest:
@Test public void longDoubleFromString() { String strValue = "1.234567890123456789"; BigDecimal value = new BigDecimal(strValue); assertEquals(value.toEngineeringString(), value.toString()); byte[] ld = new byte[Type.LONGDOUBLE.size()]; Foreign.getInstance().longDoubleFromString(value.toEngineeringString(), ld, 0, Type.LONGDOUBLE.size()); String strRetValue = Foreign.getInstance().longDoubleToString(ld, 0, 0); // String strRetValueE = Foreign.getInstance().longDoubleToEngineeringString(ld, 0, 0); BigDecimal retValue = new BigDecimal(strRetValue); BigDecimal delta = value.subtract(retValue).abs(); assertTrue("Not equals, expected: " + value.toEngineeringString() + " but was: " + retValue.toEngineeringString(), delta.compareTo(new BigDecimal("0.0000000000000000001")) < 0); }
I will poke in the c sources to figure out whats wrong...
The text was updated successfully, but these errors were encountered: