|Topic was automatically imported from the old Question2Answer platform.
I was just putting a bunch of common routines into a singleton and using static typing to future-proof myself. Without checking, I assumed that the viewport sizes would be returned as type integer but it’s apparently float and I got a “Narrowing conversion” warning.
Colour me surprised…
I can’t think why it has to be a float. Non-integral number of pixels? So many pixels that it overflows the max number that can be held in a 64-bit Integer? Rather unlikely…
If we are to use static typing in the future for performance reasons then I guess I need to understand. Some might call it a bug but one that it might not be possible to fix without breaking backwards compatibility. Wasn’t an issue before static typing. Values would get coerced when changing class but they will now raise errors.
It may be the nature of the “size” property in
Viewport. The size property uses a
Vector2, and its “x” and “y” properties use the “float” data type. When used in a
Viewport, common sense would say that they’re integers. Maybe it’s used for backwards compatibility, or maybe it’s an oversight, though I don’t really know.
Ertain | 2019-12-12 16:41