-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid adding unintended precision to numbers.
There are numbers who's decimal places, when converted, expand to the point of giving the #path_to method issues. For example: (7/6r).to_f => 1.1666666666666667 The #path_to method can handle 7/6r fine, but it doesn't handle its floating point equivalent well, taking too long to compute. Another example is 1.247265. Ruby's #to_r method converts this float to 2808591094616131/2251799813685248r, although 1247265/1000000r is simpler and matches the float's precision accurately. The former takes a long time to compute the #path_to, the latter takes considerably less time. This commit adds the Bigdecimal method #to_d to covert all floating point numbers to big decimals. Doing this conversion irons out the issues mentioned above.
- Loading branch information
Showing
4 changed files
with
48 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters