diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2011-12-11 02:03:56 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2011-12-11 02:03:56 -0800 |
commit | df456b691838fdbc1e8a7336f84c9e784fa358d5 (patch) | |
tree | c75815348cf0e111c1aa59bbf39b9bb5ec1a77ac /arith.txr | |
parent | d49893bac4c0b842765bbf491720512048a1e13c (diff) | |
download | txr-df456b691838fdbc1e8a7336f84c9e784fa358d5.tar.gz txr-df456b691838fdbc1e8a7336f84c9e784fa358d5.tar.bz2 txr-df456b691838fdbc1e8a7336f84c9e784fa358d5.zip |
* arith.c: Regenerated.
* arith.txr (highest_bit): Oops, half the logic for
the 64 bit case was missing due to to a cut and paste mistake.
Diffstat (limited to 'arith.txr')
-rw-r--r-- | arith.txr | 56 |
1 files changed, 55 insertions, 1 deletions
@@ -149,7 +149,61 @@ int highest_bit(int_ptr_t n) } } } - } + } else { + if (n & 0x00000000FFFF0000) { + if (n & 0x00000000FF000000) { + if (n & 0x00000000F0000000) { + if (n & 0x00000000C0000000) + return (n & 0x0000000080000000) ? 32 : 31; + else + return (n & 0x0000000020000000) ? 30 : 29; + } else { + if (n & 0x000000000C000000) + return (n & 0x0000000008000000) ? 28 : 27; + else + return (n & 0x0000000002000000) ? 26 : 25; + } + } else { + if (n & 0x0000000000F00000) { + if (n & 0x0000000000C00000) + return (n & 0x0000000000800000) ? 24 : 23; + else + return (n & 0x0000000000200000) ? 22 : 21; + } else { + if (n & 0x00000000000C0000) + return (n & 0x0000000000080000) ? 20 : 19; + else + return (n & 0x0000000000020000) ? 18 : 17; + } + } + } else { + if (n & 0x000000000000FF00) { + if (n & 0x000000000000F000) { + if (n & 0x000000000000C000) + return (n & 0x0000000000008000) ? 16 : 15; + else + return (n & 0x0000000000002000) ? 14 : 13; + } else { + if (n & 0x0000000000000C00) + return (n & 0x0000000000000800) ? 12 : 11; + else + return (n & 0x0000000000000200) ? 10 : 9; + } + } else { + if (n & 0x00000000000000F0) { + if (n & 0x00000000000000C0) + return (n & 0x0000000000000080) ? 8 : 7; + else + return (n & 0x0000000000000020) ? 6 : 5; + } else { + if (n & 0x000000000000000C) + return (n & 0x0000000000000008) ? 4 : 3; + else + return (n & 0x0000000000000002) ? 2 : (n ? 1 : 0); + } + } + } + } #elif SIZEOF_PTR == 4 if (n & 0x7FFF0000) { if (n & 0x7F000000) { |