You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, int::abs has a return type that's the same as its arg type, and writing int::abs(x) as uint looks very silly. I understand that it's not totally straightforward to write what we really want (basically, we want a type function that relates an int type of a given size to a uint type of a given size, and AFAICT we can't do that), but it would still be good. Maybe there's a clever workaround I'm not seeing...
The text was updated successfully, but these errors were encountered:
I am not sure if this makes sense. I imagine a common use of abs is in some formulas where the result will still be combined with other ints, not uints.
I imagine it is actually very unusual to have code where you have an int which could be negative and you need to supply that int to a uint context such that if the int is negative you want the absolute value. I could imagine something like int::to_uint() which asserted that the int was indeed positive... currently we just do i as uint which is of course unsafe in this regard.
Currently,
int::abs
has a return type that's the same as its arg type, and writingint::abs(x) as uint
looks very silly. I understand that it's not totally straightforward to write what we really want (basically, we want a type function that relates an int type of a given size to a uint type of a given size, and AFAICT we can't do that), but it would still be good. Maybe there's a clever workaround I'm not seeing...The text was updated successfully, but these errors were encountered: