java-primitive-specializations-generator icon indicating copy to clipboard operation
java-primitive-specializations-generator copied to clipboard

How to have a type literal

Open jdimeo opened this issue 5 years ago • 0 comments

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?

jdimeo avatar Mar 27 '20 01:03 jdimeo