Closed muryno closed 1 month ago
@muryno its wrong, '.' doesnt have to be always '.', it matters on your languague
this is used for it "DecimalFormatSymbols.getInstance().decimalSeparator.toString()" and in main activity there is decimalSeparatorSymbol variable
DecimalFormatSymbols @inson1 I saw that but if you try to debug the cause for why 50.0 ! is not equals 50!
it is because the . is ignored and this function private fun formatFactorial(calculation: String): String {
always return case like
factorial(50(factorial(.0)) instead of factorial(50.0)
adding the check in this PR fix the issue..
I also added a test case to validate this. you can try to put a break point at formatFactorial and see what is returned with and without decimal
@muryno its wrong, '.' doesnt have to be always '.', it matters on your languague
this is used for it "DecimalFormatSymbols.getInstance().decimalSeparator.toString()" and in main activity there is decimalSeparatorSymbol variable
But factorial forms as "3.03!" still does not work
But factorial forms as "3.03!" still does not work
I will take a look at this and update the code
@Darkempire78 The issue was due to precision loss from converting BigDecimal to double for mathematical operations, which can introduce inaccuracies in calculations, especially for functions like the Lanczos approximation that are sensitive to precision.
I have updated private fun gammaLanczos(x: BigDecimal): BigDecimal {
logic to minimizes precision loss by managing conversions between BigDecimal and double
Thank you!
@muryno I wasn't paying attention, but the pull request has created a problem. It no longer passes the calculation tests.
In fact (3!)!
no longer works.
@muryno I wasn't paying attention, but the pull request has created a problem. It no longer passes the calculation tests. In fact
(3!)!
no longer works.
@Darkempire78 will take a look at this today ..... or we can create a bug ticket and assign to me
@Darkempire78 MR fix https://github.com/Darkempire78/OpenCalc/pull/440
Fixes #314
The issue arose because the original code overlooked decimal points when identifying numbers leading up to a factorial symbol, mishandling cases like "3.0!". By adding a check for decimals, the updated code now properly handles these numbers
Before
MR result