Hi Luca,

Brad implemented a transmute method last year. I had done a crude version (which only worked with **const**, not **param** data) a few years prior. I will send you some rough doco over the weekend (unless Brad has something already). Given a **real**(w) variable `v`

, then

```
const v_as_bits = v.transmute(uint(w));
```

will return an unsigned integral type which is the same bit pattern as that **real**(w) number `v`

. Also

```
const v_as_real = v_as_bits.transmute(real(w));
assert(v == v_as_real);
assert(v == (v.transmute(uint(w)).transmute(real(w))));
```

Your definition of `sgn()`

for a complex is the original `signum()`

definition for this functionality which I think has been around since at least the early 1800s if not a little bit earlier. The name `sgn()`

did not originate for this functionality until the very early 1900s. Kronecker in about 1887 used [k] to represent `signum(k)`

for integers and his definition used the form with which we are familiar today. I hate the name `sgn()`

but that is another story. I think we can blame an Italian, Peano for that name but I am not so sure.

The implementation I provided for `sgn(z : complex(w))`

is based on a formula I have used for years in practice in my programming of engineering, physics and

geophysics applications. I believe Maple uses this same definition and it is fast for a complex number. Matlab however uses the classical definition that you quote and is slow. What is your application? I find the classical definition impractical in my work. And besides, I can write

```
inline proc signum(z) // totally generic
{
return if z == 0 then z else z / abs(z);
}
```

if I really want the classical routine. A bit slow though.

The negative field `n`

is an integer. It is never a bool. The equation as I wrote it is correct. That `n`

is only ever 0 or 1.

And yes, the standard says there **shall** be a routine `isSignMinus`

. Chapel is your friend. If you really want this routine, and I have never needed a **bool**, provide your program with

```
inline proc isSignMinus(x : real(?w)) do return signbit(x) != 0;
```

The routine `signbit()`

is a better and faster building block while `isSignMinus()`

is not well suited to being the building block.

The `sgn()`

function never returns the value of the negative field, i.e. `n`

, or what most people call the sign bit. As I often want the value `n`

I need a routine like `signbit()`

which returns that integer. If you want a **bool**, use isSignMinus as described above (which is also what Swift uses).