So I started playing around with JavaFX. Instead of going after lots of graphical goodness, I went for more mathematical stuff. I did a few problems with JavaFX, and then came across a problem that required finding the prime factors of a large integer. JavaFX has an Integer type that maps to java.lang.Integer. There is nothing in JavaFX specifically for large integers, but part of the beauty of JavaFX is that you can use classes from Java in it. In particular you can use java.math.BigInteger. So far so good.
In my solution, I wrote a prime sieve and then checked the modulus of the primes against the large integer. Now for normal 32-bit Integers, JavaFX has some nice syntax:
var remainder = n mod p;
It looks like math! Of course I love this. However, this does not work for BigIntegers. No problem, BigInteger has its own method for this:
var remainder = n.mod(p);
But this does not compile! Why? As you can infer from the first example, mod is a reserved word in JavaFX, so you can't use it as an identifier. Thus you can't use it as a method name. Of course you could surely use reflection to get around this, but who wants to do that?
2 comments:
Ouch! This reminds me of "assert" and having to rename methods named assert(...)
Thanks for sharing! I like your blog and keep upadte us.
Chatbot companies in india,
Chatbot development company,
Chatbot companies,
Messenger bot developer,
Facebook bot development,
Chatbot developer,
Bot developer,
Post a Comment