Closed stefanhamburger closed 6 years ago
There is an error in the string() function from the big_rational library (in the book on page 5.7).
In the first branch of the if statement, the nr_places argument is expected to be defined, so the condition must be negated.
nr_places
Example code to reproduce (throws "TypeError: big is undefined" but prints the correct values with this fix):
import big_integer from './big_integer.js'; import big_rational from './big_rational.js'; const eight_thirds = big_rational.make(8, 3); console.log(big_rational.string(eight_thirds)); // 2 2/3 console.log(big_rational.string(eight_thirds, big_integer.make(2))); // 2.67 const ten_thirds = big_rational.make(10, 3); console.log(big_rational.string(ten_thirds)); // 3 1/3 console.log(big_rational.string(ten_thirds, big_integer.make(2))); // 3.33
Thank you so much.
There is an error in the string() function from the big_rational library (in the book on page 5.7).
In the first branch of the if statement, the
nr_places
argument is expected to be defined, so the condition must be negated.Example code to reproduce (throws "TypeError: big is undefined" but prints the correct values with this fix):