Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /homepages/11/d274290037/htdocs/serabe/wp-content/plugins/jetpack/_inc/lib/class.media-summary.php on line 77

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /homepages/11/d274290037/htdocs/serabe/wp-content/plugins/jetpack/_inc/lib/class.media-summary.php on line 87
The One where I spent a morning because -0.5 turned to be parsed as 1/2 | Conecto ergo sum.
Warning: Use of undefined constant user_level - assumed 'user_level' (this will throw an Error in a future version of PHP) in /homepages/11/d274290037/htdocs/serabe/wp-content/plugins/ultimate-google-analytics/ultimate_ga.php on line 524

Warning: count(): Parameter must be an array or an object that implements Countable in /homepages/11/d274290037/htdocs/serabe/wp-includes/post-template.php on line 284

Warning: Use of undefined constant user_level - assumed 'user_level' (this will throw an Error in a future version of PHP) in /homepages/11/d274290037/htdocs/serabe/wp-content/plugins/ultimate-google-analytics/ultimate_ga.php on line 524

The One where I spent a morning because -0.5 turned to be parsed as 1/2


Warning: Use of undefined constant user_level - assumed 'user_level' (this will throw an Error in a future version of PHP) in /homepages/11/d274290037/htdocs/serabe/wp-content/plugins/ultimate-google-analytics/ultimate_ga.php on line 524

This summer, I have been doing some amazing stuff for GeoGebra. First of all, I would like to thank two people: Miguel, my mentor, who guided me through all that really advanced mathematical stuff; and Heinz Kredel, JAS creator and developer, who answered all my questions and implemented my suggestions as quickly as I could write them.

This story is about a problem we found in JAS. It was really subtle, so I may need a brief introduction to the project I worked on: LocusEqu. That project retrieves the equation of “any” geometrical locus. If you don’t know what a locus is, Wolfram Math World defines it as “the set of all points (usually forming a curve or surface) satisfying some condition” . LocusEqu generates a few EquationExpression, and then, by using a EquationTranslator, it generates a GenPolynomial<BigRational> object.

For translating doubles, it calls the BigRational constructor whose only argument is a String. This is the code:

Can you spot the bug? Look at the 21st line. If s is “-0.5”, then n is new BigInteger(“-0”), and that’s what makes “-0.5” be parsed as 1/2.

Leave a Comment


Warning: Use of undefined constant user_level - assumed 'user_level' (this will throw an Error in a future version of PHP) in /homepages/11/d274290037/htdocs/serabe/wp-content/plugins/ultimate-google-analytics/ultimate_ga.php on line 524

Warning: Use of undefined constant user_level - assumed 'user_level' (this will throw an Error in a future version of PHP) in /homepages/11/d274290037/htdocs/serabe/wp-content/plugins/ultimate-google-analytics/ultimate_ga.php on line 524