-
-
Save chikoski/1eff2477bac1757ab95c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| var add = function(a, b){ | |
| var bunshi; | |
| var bunbo; | |
| if(Number.isInteger(b)){ | |
| b = frac(b, 1); | |
| } | |
| if(a.bunbo != b.bunbo){ | |
| bunshi = a.bunshi * b.bunbo + b.bunshi * a.bunbo; | |
| bunbo = a.bunbo * b.bunbo; | |
| }else{ | |
| bunshi = a.bunshi + b.bunshi; | |
| bunbo = a.bunbo; | |
| } | |
| var answer = frac(bunshi, bunbo); | |
| return answer; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment