java-primitive-specializations-generator
java-primitive-specializations-generator copied to clipboard
How to have a type literal
One of my methods always returns a double regardless of the dimension (a ratio of overlap of two boxes, which is between 0.0 and 1.0 regardless of if the boxes are int, float, etc.
The last line of my method is
return ox * oy / getArea();
If the dimension is already a double, no problem. If it's an int or long, I need to cast area first so that it doesn't do integer division. How do I inject a (double) getArea() into the template but only when the dimension is not a double?