Skip to content
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

NPV calculation has side effects #28

Open
adailey14 opened this issue Mar 10, 2014 · 1 comment
Open

NPV calculation has side effects #28

adailey14 opened this issue Mar 10, 2014 · 1 comment
Assignees

Comments

@adailey14
Copy link

the NPV calculation (and probably others) have unexpected side effects on the input array. It will turn all numbers in the input array into DecNums.

Example:

x = [1,2,3]
=> [1, 2, 3]
x.npv(1.5)
=> DecNum('2.28')
x
=> [DecNum('1'), DecNum('2'), DecNum('3')]

This example is from the rails console using ruby 2.0.0-p353 and rails 3.2.13

@tubedude
Copy link

tubedude commented May 9, 2014

@adailey14 , I was able to solve this issue adding an intermediary variable to the NVP ( #30 ) calculation. I haven't tested it much, but it preserves the original array:
tubedude@412118c

x = [1,2,3] # => [1, 2, 3]
x.npv(1.5) # =>DecNum('2.28')
x # => [1, 2, 3]

@marksweston marksweston self-assigned this Dec 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants