Reinterpret an unsigned 32-bit value held in [0, 2**32) as the signed
int32 with the same bit pattern. Done arithmetically rather than with
transfer, and without ever passing an out-of-range value to int.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int64), | intent(in) | :: | u |
pure function u32_to_int32(u) result(r) !! Reinterpret an unsigned 32-bit value held in [0, 2**32) as the signed !! `int32` with the same bit pattern. Done arithmetically rather than with !! `transfer`, and without ever passing an out-of-range value to `int`. integer(int64), intent(in) :: u integer(int32) :: r if (u >= TWO_TO_31) then r = int(u - TWO_TO_32, int32) else r = int(u, int32) end if end function u32_to_int32