While solving a puzzle I encountered the fact that the auto-generated code used the Float type to work with floating-point numbers, which led to errors during tests, namely, there was not enough precision.
Example:
Found: 3 4 43.195312
Expected: 3 4 43.1953125
And so the question arose why CG uses Float by default for floating-point numbers, and not Double?
If there is a recommendation for Java programmers to use Double when working with floating-point numbers, and only if you understand why you should use Float, only in this case use Float.
I seldom use float or Float, mainly using double or Double (sometimes BigDecimal) for float-points in java.
All Math.* functions get inputs by double, output double. Why bother with float?
Rumor says float is “shorter” and “faster” than double. Wrong!
float is shorter in memory but when pumped into CPU nearly all modern processors will elevate them as double to process. There is no saving in speed. Just a little saving in memory.
The benefits of high precision outrun all memory saving.
This is what I choose to use. System default is another issue.
CG’s system design has its limitation making them difficult to customize too much for each puzzle or language. The given template code works is the basic satisfying standard. It is programmers’ own responsibility to modify to improve the default template codes if they have other preferences.
I don’t see what the problem could be when implementing a code generator for java, where double will be used for floating point numbers, not float.
As far as I understand, there is some kind of table of type correspondence between different languages, and all you need to do is change all the fields in this table for java, from float to double.