Darkempire78 / OpenCalc

A simple and beautiful calculator for Android
GNU General Public License v3.0
740 stars 83 forks source link

Factorials on floating point values #314

Closed Cosy-harks closed 2 months ago

Cosy-harks commented 8 months ago

Describe the bug

"Factorial operation" on "floating point values" is returning "bad values."

(Examples) .9! = 0.1416504592 0.9! = 0.7016202463 9.9! = 0.7016202463 π! = 5.1427625509 3.1415! = 0.2075431593

To Reproduce Steps to reproduce the behavior:

  1. Go to 'calculator.' I was in portrait orientation
  2. Click on '3' > '!'
  3. Move cursor between '3' & '!' > click on '.' > '0'
  4. Returned values are '6' > ' ' > '1'

Expected behavior A clear and concise description of what you expected to happen.

I expect '3!' to be equal to '3.0!' = '6' It seems to ignore the 'whole part' of a non-integer number and does something very different when the 'whole part' is missing.

Smartphone (please complete the following information):

Additional context

"An approximation" for "positive non integer numbers" https://en.wikipedia.org/wiki/Lanczos_approximation