From the javadoc comments in Math.java: “If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.” Let me just point out that Java thinks that NaN (Not a Number), positive zero, negative zero, or either positive or negative infinity are different values, andContinue reading “Followup”
Tag Archives: math
Next Homework Program: Ratio Exercise
The Badb just had a couple of weeks of reviewing ratios. This was a good limbering-up exercise, since the problem sets were all about converting between different units and manipulating fractions. After all, ratios are just a different way of writing fractions. The general form of the problems wound up being, “Given that the ratioContinue reading “Next Homework Program: Ratio Exercise”
Prime Factorization – Actual Code
I finally had a little time free and put together a solution to the prime factorization problem. As with the tic-tac-toe program before, there are lots of opportunities to make this program better. This only runs once, rather than looping. The number being factored is a constant so you have to edit the program toContinue reading “Prime Factorization – Actual Code”
Always Ask One More Question
Badb just asked me if I could show her how to calculate the square root of a number. I cast my mind back to 7th grade and tried to remember going up to the blackboard and calculating arbitrary square roots. “Um, yeah, but let me go look it up. It’s been a long time andContinue reading “Always Ask One More Question”
Programming Assignment: Prime Factorization
Last night the Badb had to find the prime factorization of a number. Thrill moment! This is exactly the problem I once wrote a computer program to solve and wound up entering that program in the school science fair. That was pretty cool. Back when I had to solve this problem, my computer had aContinue reading “Programming Assignment: Prime Factorization”