Open
Description
Can I suggest using raw Chapel with the transmute() feature:
inline proc signbit(param x : real(?w)) param
{
return (x.transmute(uint(w))) >> (w - 1);
}
inline proc signbit(const x : real(?w))
{
return (x.transmute(uint(w))) >> (w - 1);
}
A lot cleaner and simpler that what exists. You can even use do to shorten these.
A bit is a uint(1) if such a thing existed. Unless I am missing something, it is not a bool. Current practice has the proc returning a bool result which means an extra operation would be needed during the routine. And if I want it as a bit, then I need to cast it back again. Sounds wasteful to me.
If you really want a bool, then cast the result like
signbit(x):bool