Skip to content

Commit

Permalink
Fixes #10
Browse files Browse the repository at this point in the history
  • Loading branch information
leonelcamara committed Aug 21, 2021
1 parent f820435 commit 82022a1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# hotxlfp changelog

## 0.0.15

* Fixed bugs in FLOOR function.

## 0.0.14

* Fixed using a parser within a parser.
Expand Down
9 changes: 6 additions & 3 deletions hotxlfp/formulas/mathtrig.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,14 @@ def FLOOR(number, significance=1):
if number > 0 and not significance > 0:
return error.NUM

significance = abs(significance)
abs_significance = abs(significance)
if number >= 0:
return math.floor(number / significance) * significance
return math.floor(number / abs_significance) * abs_significance
else:
return -1 * math.floor(abs(number) / significance) * significance
func = math.floor
if significance > 0:
func = math.ceil
return -1 * func(abs(number) / abs_significance) * abs_significance


@dispatcher.register_for('POWER')
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

setup(
name='hotxlfp',
version='0.0.14',
version='0.0.15',
packages=['hotxlfp', 'hotxlfp._compat', 'hotxlfp._compat.py3', 'hotxlfp.helper', 'hotxlfp.formulas', 'hotxlfp.grammarparser'],
license='MIT',
test_suite='tests',
author='Leonel Câmara',
author_email='[email protected]',
url='https://github.com/aidhound/hotxlfp',
download_url='https://github.com/aidhound/hotxlfp/archive/0.0.13.tar.gz',
download_url='https://github.com/aidhound/hotxlfp/archive/0.0.15.tar.gz',
keywords=['excel', 'formula', 'parser'],
install_requires=['ply', 'python-dateutil'],
long_description='\n'.join(l for l in open('README.md', encoding="utf-8").readlines() if not l.startswith('[!')),
Expand Down
7 changes: 7 additions & 0 deletions tests/test_mathtrig.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,13 @@ def test_floor(self):
ret = p.parse('FLOOR(0.234,0.01)')
self.assertEqual(ret['result'], 0.23)
self.assertEqual(ret['error'], None)
ret = p.parse('FLOOR(-5.6; 1)')
self.assertEqual(ret['result'], -6)
self.assertEqual(ret['error'], None)
ret = p.parse('FLOOR(-5.6; -1)')
self.assertEqual(ret['result'], -5)
self.assertEqual(ret['error'], None)


def test_quotient(self):
p = Parser(debug=True)
Expand Down

0 comments on commit 82022a1

Please sign in to comment.