Index

0-bits, leading zeros. See nlz function.

0-bits, trailing zeros. See also ntz (number of trailing zeros) function.

counting, 107114.

detecting, 324. See also CRC (cyclic redundancy check).

plots and graphs, 466

0-bytes, finding, 117121

1-bits, counting. See Counting bits.

3:2 compressor, 9095

The 16 Boolean binary operations, 5357

A

Absolute value

computing, 18

multibyte, 4041

negative of, 2326

add instruction

condition codes, 3637

propagating arithmetic bounds, 7073

Addition

arithmetic tables, 453

combined with logical operations, 1617

double-length, 3839

multibyte, 4041

of negabinary numbers, 301302

overflow detection, 2829

plots and graphs, 461

in various number encodings, 304305

Advanced Encryption Standard, 164

Alternating among values, 4851

Alverson‘s method, 237238

and

plots and graphs, 459

in three instructions, 17

and with complement, 131

Answers to exercises, by chapter

1: Introduction, 405406

2: Basics, 407415

3: Power-of-2 Boundaries, 415416

4: Arithmetic Bounds, 416417

5: Counting Bits, 417418

6: Searching words, 418423

7: Rearranging Bits and Bytes, 423425

8: Multiplication, 425428

9: Integer Division, 428430

10: Integer Division by Constants, 431434

11: Some Elementary Functions, 434435

12: Unusual Bases for Number Systems, 435439

13: Gray Code, 439441

14: Cyclic Redundancy Check, 441442

15: Error-Correcting Codes, 442445

16: Hilbert‘s Curve, 446

17: Floating-Point, 446448

18: Formulas for Primes, 448452

Arithmetic, computer vs. ordinary, 1

Arithmetic bounds

checking, 6769

of expressions, 7071

propagating through, 7073

range analysis, 70

searching for values in, 122

Arithmetic tables, 4-bit machine, 453456

Arrays

checking bounds. See Arithmetic bounds.

counting 1-bits, 8996

indexes, checking. See Arithmetic bounds.

indexing a sparse array, 95

permutation, 161163

rearrangements, 165166

of short integers, 4041

Autodin-II polynomial, 323

Average, computing, 19, 5556

B

Base –1 + i number system, 306308

extracting real and imaginary parts, 310

Base –1 – i number system, 308309

Base –2 number system, 299306

Gray code, 315

rounding down, 310

Basic RISC instruction set, 56

Basic, Wang System 2200B, 55

Big-endian format, converting to little-endian, 129

Binary decomposition, integer exponentiation, 288290

Binary forward error-correcting block codes (FEC), 331

Binary search

counting leading 0‘s, 99104

integer logarithm, 291297

integer square root, 279287

Bit matrices, multiplying, 98

Bit operations

compress operation, 150156

computing parity. See Parity.

counting bits. See Counting bits.

finding strings of 1-bits, 123128

flipping bits, 135

general permutations, 161165

generalized bit reversal, 135

generalized extract, 150156

half shuffle, 141

inner perfect shuffle, plots and graphs, 468469

inner perfect unshuffle, plots and graphs, 468

inner shuffle, 139141

numbering schemes, 1

outer shuffle, 139141, 373

perfect shuffle, 139141

reversing bits. See Reversing bits and bytes.

on rightmost bits. See Rightmost bits.

searching words for bit strings, 107, 123128

sheep and goats operation, 161165

shuffling bits, 139141, 165166

transposing a bit matrix, 141150

unshuffling bits, 140141, 150, 162

Bit reversal function, plots and graphs, 467

Bit vectors, 1

bitgather instruction, 163165

Bits. See specific topics.

bitsize function, 106107

Bliss, Robert D., xv

Bonzini, Paolo, 263

BOOL function, 5455

Boole, George, 54

Boolean binary operations, all 16, 5357

Boolean decomposition formula, 5153, 5657

Boundary crossings, powers of 2, 6364

Bounds, arithmetic. See Arithmetic bounds.

Bounds checking. See Checking arithmetic bounds.

branch on carry and register result nonzero instruction, 63

Bytes. See also specific topics.

definition, 1

finding first 0-byte, 117121

C

C language

arithmetic on pointers, 105, 240

GNU extensions, 105

iIterative statements, 4, 10

referring to same location with different types, 104

representation of character strings, 117

summary of elements, 24

Caches, 166-167

Carry-save adder (CSA) circuit, 9095

CCITT (Le Comité Consultatif Internationale...), 321

Ceiling function, identities, 183184

Chang, Albert, 123

Character strings, 117

Check bits

Hamming code, 332

SEC-DED code, 334335

Checking arithmetic bounds, 6769

Chinese ring puzzle, 315

Chipkill technology, 336

Code, definition, 343

Code length, 331, 343

Code rate, 343

Code size, 343

Comparison predicates

from the carry bit, 2627

definition, 23

number of leading zeros (nlz) function, 2324, 107

signed comparisons, from unsigned, 25

true/false results, 23

using negative absolute values, 2326

Comparisons

computer evaluation of, 27

floating-point comparisons using integer operations, 381382

three-valued compare function, 2122. See also sign function.

Compress function, plots and graphs, 464465

compress operation, 119, 150161

with insert and extract instructions, 155156

Computability test, right-to-left, 1314, 55

Computer algebra, 24

Computer arithmetic

definition, 1

plots and graphs, 461463

Condition codes, 3637

Constants

dividing by. See Division of integers by constants.

multiplying by, 175178

Counting bits. See also ntz (number of trailing zeros) function; nlz (number of leading zeros) function; population count function.

1-bits in

7- and 8-bit quantities, 87

an array, 8995

a word, 8188

bitsize function, 106107

comparing two words, 8889

divide and conquer strategy, 8182

leading 0‘s, with

binary search method, 99100

floating-point methods, 104106

population count instruction, 101102

rotate and sum method, 8586

search tree method, 109

with table lookup, 8687

trailing 0‘s, 107114

by turning off 1-bits, 85

CRC (cyclic redundancy check)

background, 319320

check bits, generating, 319320

checksum, computing

generator polynomials, 322323, 329

with hardware, 324326

with software, 327329

with table lookup, 328329

techniques for, 320

code vector, 319

definition, 319

feedback shift register circuit, 325326

generator polynomial, choosing, 322323, 329

parity bits, 319320

practice

hardware checksums, 324326

leading zeros, detecting, 324

overview, 323324

residual/residue, 324

software checksums, 327329

trailing zeros, detecting, 324

theory, 320323

CRC codes, generator polynomials, 322, 323

CRC-CITT polynomial, 323

Cryptography

Advanced Encryption Standard, 164

bitgather instruction, 164165

DES (Data Encryption Standard), 164

Rijndael algorithm, 164

SAG method, 162165

shuffling bits, 139141, 165

Triple DES, 164

CSA (carry-save addr) circuit, 9095

Cube root, approximate, floating-point, 389

Cube root, integer, 287288

Curves. See also Hilbert‘s curve.

Peano, 371372

space-filling, 355372

Cycling among values, 4851

D

Davio decomposition, 51-53, 5657

de Bruijn cycles, 111112

de Kloet, David, 55

De Morgan‘s laws, 1213

DEC PDP-10 computer, xiii, 84

Decryption. See Cryptography.

DES (Data Encryption Standard), 164

Dietz‘s formula, 19, 55

difference or zero (doz) function, 4145

Distribution of leading digits, 385387

Divide and conquer strategy, 8182

Division

arithmetic tables, 455

doubleword

from long division, 197202

signed, 201202

by single word, 192197

unsigned, 197201

floor, 181182, 237

modulus, 181182, 237

multiword, 184188

of negabinary numbers, 302304

nonrestoring algorithm, 192194

notation, 181

overflow detection, 3436

plots and graphs, 463464

restoring algorithm, 192193

shift-and-subtract algorithms (hardware), 192194

short, 189192, 195197

signed

computer, 181

doubleword, 201202

long, 189

multiword, 188

short, 190192

unsigned

computer, 181

doubleword, 197201

long, 192197

short from signed, 189192

Division of integers by constants

by 3, 207209, 276277

by 5 and 7, 209210

exact division

converting to, 274275

definition, 240

multiplicative inverse, Euclidean algorithm, 242245

multiplicative inverse, Newton‘s method, 245247

multiplicative inverse, samples, 247248

floor division, 237

incorporating into a compiler, signed, 220223

incorporating into a compiler, unsigned, 232234

magic numbers

Alverson‘s method, 237238

calculating, signed, 212213, 220223

calculating, unsigned, 231234

definition, 211

sample numbers, 238239

table lookup, 237

uniqueness, 224

magicu algorithm, 232234

magicu2 algorithm, 236

modulus division, 237

remainder by multiplication and shifting right

signed, 273274

unsigned, 268272

remainder by summing digits

signed, 266268

unsigned, 262266

signed

by divisors ≤ –2, 218220

by divisors ≥ 2, 210218

by powers of 2, 205206

incorporating into a compiler, 220223

not using mulhs (multiply high signed), 259262

remainder by multiplication and shifting right, 273274

remainder by summing digits, 266268

remainder from powers of 2, 206207

test for zero remainder, 250251

uniqueness, 224

timing test, 276

unsigned

best programs for, 234235

by 3 and 7, 227229

by divisors ≥ 1, 230232

by powers of 2, 227

incorporating into a compiler, 232234

incremental division and remainder technique, 232234

not using mulhu (multiply high unsigned) instruction, 251259

remainder by multiplication and shifting right, 268272

remainder by summing digits, 262266

remainder from powers of 2, 227

test for zero remainder, 248250

Double buffering, 46

Double-length addition/subtraction, 3839

Double-length shifts, 3940

Doubleword division

by single word, 192197

from long division, 197202

signed, 201202

unsigned, 197201

Doublewords, definition, 1

doz (difference or zero) function, 4145

Dubé, Danny, 112

E

ECCs (error-correcting codes)

check bits, 332

code, definition, 343

code length, 331, 343

code rate, 343

code size, 343

coding theory problem, 345351

efficiency, 343

FEC (binary forward error-correcting block codes), 331

Gilbert-Varshamov bound, 348350

Hamming bound, 348, 350

Hamming code, 332-342

converting to SEC-DED code, 334337

extended, 334337

history of, 335337

overview, 332334

SEC-DED on 32 information bits, 337342

Hamming distance, 95, 343345

information bits, 332

linear codes, 348349

overview, 331, 342343

perfect codes, 333, 349, 352

SEC (single error-correcting) codes, 331

SEC-DED (single error-correcting, double error-detecting) codes

on 32 information bits, 337342

check bits, minimum required, 335

converting from Hamming code, 334337

definition, 331

singleton bound, 352

sphere-packing bound, 348, 350

spheres, 347351

Encryption. See Cryptography.

End-around-carry, 38, 56, 304305

Error detection, digital data. See CRC (cyclic redundancy check).

Estimating multiplication overflow, 3334

Euclidean algorithm, 242245

Euler, Leonhard, 392

Even parity, 96

Exact division

definition, 240

multiplicative inverse, Euclidean algorithm, 242245

multiplicative inverse, Newton‘s method, 245247

multiplicative inverse, samples, 247248

overview, 240242

Exchanging

conditionally, 47

corresponding register fields, 46

two fields in same register, 47

two registers, 4546

exclusive or

plots and graphs, 460

propagating arithmetic bounds through, 7778

scan operation on an array of bits, 97

in three instructions, 17

Execution time model, 910

Exercise answers. See Answers to exercises.

Expand operation, 156157, 159161

Exponentiation

by binary decomposition, 288290

in Fortran, 290

Extended Hamming code, 334342

on 32 information bits, 337-342

Extract, generalized, 150156

F

Factoring, 178

FEC (binary forward error-correcting block codes), 331

feedback shift register circuit, 325326

Fermat numbers, 391

FFT (Fast Fourier Transform), 137139

find leftmost 0-byte, 117121

find rightmost 0-byte, 118121

Finding

decimal digits, 122

first 0-byte, 117121

first uppercase letter, 122

length of character strings, 117

next higher number, same number of 1-bits, 1415

the nth prime, 391398, 403

strings of 1-bits

first string of a given length, 123125

longest string, 125126

shortest string, 126128

values within arithmetic bounds, 122

Flipping bits, 135

Floating-point numbers, 375389

distribution of leading digits, 385387

formats (single/double), 375376

gradual underflow, 376

IEEE arithmetic standard, 375

IEEE format, 375377

NaN (not a number), 375376

normalized, 375377

subnormal numbers, 375377

table of miscellaneous values, 387389

ulp (unit in the last position), 378

Floating-point operations

approximate cube root, 389

approximate reciprocal square root, 383385

approximate square root, 389

comparing using integer operations, 381382

conversion table, 378381

converting to/from integers, 377381

counting leading 0‘s with, 104106

simulating, 107

Floor division, 181182, 237

Floor function, identities, 183, 202203

Floyd, R. W., 114

Formula functions, 398403

Formulas for primes, 391403

Fortran

IDIM function, 44

integer exponentiation, 290

ISIGN function, 22

MOD function, 182

Fractal triangles, plots and graphs, 460

Full adders, 90

Full RISC instruction set, 7

Fundamental theorem of arithmetic, 404

G

Gardner, Martin, 315

Gaudet, Dean, 110

Gaudet‘s algorithm, 110

generalized extract operation, 150156

Generalized unshuffle. See SAG (sheep and goats) operation.

Generator polynomials, CRC codes, 321323

Gilbert-Varshamov bound, 348350

Golay, M. J. E., 331

Goryavsky, Julius, 103

Gosper, R. W.

iterating through subsets, 1415

loop-detection, 114116

Gradual underflow, 376

Graphics-rendering, Hilbert‘s curve, 372373

Graphs. See Plots and graphs.

Gray, Frank, 315

Gray code

applications, 315317

balanced, 317

converting integers to, 97, 312313

cyclic, 312

definition, 311

history of, 315317

incrementing Gray-coded integers, 313315

negabinary Gray code, 315

plots and graphs, 466

reflected, 311312, 315

single track (STGC), 316317

Greatest common divisor function, plots and graphs, 464

GRP instruction, 165

H

Hacker, definition, xvi

HAKMEM (hacks memo), xiii

Half shuffle, 141

Halfwords, 1

Hamiltonian paths, 315

Hamming, R. W., 331

Hamming bound, 348, 350

Hamming code

on 32 information bits, 337342

converting to SEC-DED code, 334337

extended, 334337

history of, 335337

overview, 332334

perfect, 333, 352

Hamming distance, 95, 343345

triangle inequality, 352

Hardware checksums, 324326

Harley, Robert, 90, 101

Harley‘s algorithm, 101, 103

Hexadecimal floating-point, 385

High-order half of product, 173174

Hilbert, David, 355

Hilbert‘s curve. See also Space-filling curves.

applications, 372373

coordinates from distance

curve generator driver program, 359

description, 358366

Lam and Shapiro method, 362364, 368

parallel prefix operation, 365366

state transition table, 361, 367

description, 355356

distance from coordinates, 366368

generating, 356358

illustrations, 355, 357

incrementing coordinates, 368371

non-recursive generation, 371

ray tracing, 372

three-dimensional analog, 373

Horner‘s rule, 49

I

IBM

Chipkill technology, 336

Harvest computer, 336

PCs, error checking, 336

PL/I language, 54

Stretch computer, 81, 336

System/360 computer, 385

System/370 computer, 63

IDIM function, 44

IEEE arithmetic standard, 375

IEEE format, floating-point numbers, 375377

IEEE Standard for Floating-Point Arithmetic, 375

Image processing, Hilbert‘s curve, 372

Incremental division and remainder technique, 232234

Inequalities, logical and arithmetic expressions, 1718

Information bits, 332

Inner perfect shuffle function, plots and graphs, 468469

Inner perfect unshuffle function, plots and graphs, 468

Inner shuffle, 139141

insert instruction, 155156

Instruction level parallelism, 9

Instruction set for this book, 58

integer cube root function, 287288, 297

Integer exponentiation, 288290

integer fourth root function, 297

integer log base 2 function, 106, 291

integer log base 10 function, 292297

Integer quotient function, plots and graphs, 463

integer remainder function, 463

integer square root function, 279287

Integers. See also specific operations on integers.

complex, 306309

converting to/from floating-point, 377381

converting to/from Gray code, 97, 312313

reversed, incrementing, 137139

reversing, 129137

Inverse Gray code function

formula, 312

plots and graphs, 466

An Investigation of the Laws of Thought, 54

ISIGN (transfer of sign) function, 22

Iterating through subsets, 1415

ITU-TSS (International Telecommunications Union...), 321

ITU-TSS polynomial, 323

K

Knuth, Donald E., 132

Knuth‘s Algorithm D, 184188

Knuth‘s Algorithm M, 171172, 174175

Knuth‘s mod operator, 181

Kronecker, Leopold, 375

L

Lam and Shapiro method, 362364, 368

Landry, F., 391

Leading 0‘s, counting, 99106. See also nlz (number of leading zeros) function.

Leading 0’s, detecting, 324. See also CRC (cyclic redundancy check).

Leading digits, distribution, 385387

Least common multiple function, plots and graphs, 464

Linear codes, 348349

Little-endian format, converting to/from big-endian, 129

load word byte-reverse (lwbrx) instruction, 118

Logarithms

binary search method, 292293

definition, 291

log base 2, 106107, 291

log base 10, 291297

table lookup, 292, 294297

Logical operations

with addition and subtraction, 1617

and, plots and graphs, 459

binary, table of, 17

exclusive or, plots and graphs, 460

or, plots and graphs, 459

propagating arithmetic bounds through, 7476, 78

tight bounds, 7478

Logical operators on integers, plots and graphs, 459460

Long Division, definition, 189

Loop detection, 114115

LRU (least recently used) algorithm, 166169

lwbrx (load word byte-reverse) instruction, 118

M

MacLisp, 55

magic algorithm

incremental division and remainder technique, 232234

signed division, 220223

unsigned division, 232234

Magic numbers

Alverson‘s method, 237238

calculating, signed, 212213, 220223

calculating, unsigned, 232234

calculating, Python code for

definition, 211

samples, 238239

table lookup, 237

uniqueness, 224

magicu algorithm, 232234

in Python, 240

magicu2 algorithm, 236237

max function, 4145

Mills, W. H., 403

Mills’s theorem, 403404

min function, 4145

MIT PDP-6 Lisp, 55

MOD function (Fortran), 182

modu (unsigned modulus) function, 98

Modulus division, 181182, 237

Moore, Eliakim Hastings, 371372

mulhs (multiply high signed) instruction

division with, 207210, 212, 218, 222, 235

implementing in software, 173174

not using, 259262

mulhu (multiply high unsigned) instruction

division with, 228229, 234235, 238

implementing in software, 173

not using, 251259

Multibyte absolute value, 4041

Multibyte addition/subtraction, 4041

Multiplication

arithmetic tables, 454

of complex numbers, 178179

by constants, 175178

factoring, 178

low-order halves independent of signs, 178

high-order half of 64-bit product, 173174

high-order product signed from/to unsigned, 174175

multiword, 171173

of negabinary numbers, 302

overflow detection, 3134

plots and graphs, 462

Multiplicative inverse

Euclidean algorithm, 242245

Newton‘s method, 245247, 278

samples, 247248

multiply instruction, condition codes, 3637

Multiword division, 184189

Multiword multiplication, 171173

mux (multiplex) operation, 42, 56, 131, 163, 406

N

NAK (negative acknowledgment), 319

NaN (not a number), 375376

Negabinary number system, 299306

Gray code, 315

Negative absolute value, 2326

Negative overflow, 30

Newton-Raphson calculation, 383

Newton‘s method, 457458

integer cube root, 287288

integer square root, 279283

multiplicative inverse, 245248

Next higher number, same number of 1-bits, 1415

Nibbles, 1

nlz (number of leading zeros) function

applications, 79, 107, 128

bitsize function, 106107

comparison predicates, 2324, 107

computing, 99106

for counting trailing 0‘s, 107

finding 0-bytes, 118

finding strings of 1-bits, 123124

incrementing reversed integers, 138

and integer log base 2 function, 106

rounding to powers of 2, 61

Nonrestoring algorithm, 192194

Normalized numbers, 376

Notation used in this book, 14

nth prime, finding

formula functions, 398401

Willans‘s formulas, 393397

Wormell‘s formula, 397398

ntz (number of trailing zeros) function

applications, 114116

from counting leading 0‘s, 107

loop detection, 114115

ruler function, 114

Number systems

base –1 + i, 306308

base –1 – i, 308309

base –2, 299306, 315

most efficient base, 309310

negabinary, 299306, 315

O

Odd parity, 96

1-bits, counting. See Counting bits.

or

plots and graphs, 459

in three instructions, 17

Ordinary arithmetic, 1

Ordinary rational division, 181

Outer perfect shuffle bits function, plots and graphs, 469

Outer perfect shuffle function, plots and graphs, 467

Outer perfect unshuffle function, plots and graphs, 468

Outer shuffle, 139141, 373

Overflow detection

definition, 28

division, 3436

estimating multiplication overflow, 3334

multiplication, 3134

negative overflow, 30

signed add/subtract, 2830

unsigned add/subtract, 31

P

Parallel prefix operation

definition, 97

Hilbert‘s curve, 364366

inverse, 116

parity, 97

Parallel suffix operation

compress operation, 150155

expand operation, 156157, 159161

generalized extract, 150156

inverse, 116

Parity

adding to 7-bit quantities, 98

applications, 98

computing, 9698

definition, 96

parallel prefix operation, 97

scan operation, 97

two-dimensional, 352

Parity bits, 319320

PCs, error checking, 336

Peano, Giuseppe, 355

Peano curves, 371372. See also Hilbert‘s curve.

Peano-Hilbert curve. See Hilbert‘s curve.

Perfect codes, 333, 349

Perfect shuffle, 139141, 373

Permutations on bits, 161165. See also Bit operations.

Planar curves, 355. See also Hilbert‘s curve.

Plots and graphs, 459469

addition, 461

bit reversal function, 467

compress function, 464465

division, 463464

fractal triangles, 460

Gray code function, 466

greatest common divisor function, 464

inner perfect shuffle, 468469

inner perfect unshuffle, 468

integer quotient function, 463

inverse Gray code function, 466

least common multiple function, 464

logical and function, 459

logical exclusive or function, 460

logical operators on integers, 459460

logical or function, 459

multiplication, 462

number of trailing zeros, 466

outer perfect shuffle, 467469

outer perfect unshuffle, 468

population count function, 467

remainder function, 463

rotate left function, 465

ruler function, 466

SAG (sheep and goats) function, 464465

self-similar triangles, 460

Sierpinski triangle, 460

subtraction, 461

unary functions, 466469

unsigned product of x and y, 462

Poetry, 278, 287

population count function. See also Counting bits.

applications, 9596

computing Hamming distance, 95

counting 1-bits, 81

counting leading 0‘s, 101102

counting trailing 0‘s, 107114

plots and graphs, 467

Position sensors, 315317

Powers of 2

boundary crossings, detecting, 6364

rounding to, 5962, 64

signed division, 205206

unsigned division, 227

PPERM instruction, 165

Precision, loss of, 385386

Prime numbers

Fermat numbers, 391

finding the nth prime

formula functions, 398403

Willans‘s formulas, 393397

Wormell‘s formula, 397398

formulas for, 391403

from polynomials, 392

Propagating arithmetic bounds

add and subtract instructions, 7073

logical operations, 7378

signed numbers, 7173

through exclusive or, 7778

PSHUFB (Shuffle Packed Bytes) instruction, 163

PSHUFD (Shuffle Packed Doublewords) instruction, 163

PSHUFW (Shuffle Packed Words) instruction, 163

Q

Quicksort, 81

R

Range analysis, 70

Ray tracing, Hilbert‘s curve, 372

Rearrangements and index transformations, 165166

Reed-Muller decomposition, 51-53, 5657

Reference matrix method (LRU), 166169

Reflected binary Gray code, 311312, 315

Registers

exchanging, 4546

exchanging conditionally, 47

exchanging fields of, 4647

reversing contents of, 129135

RISC computers, 5

Reiser, John, 113

Reiser‘s algorithm, 113114

Remainder function, plots and graphs, 463

Remainders

arithmetic tables, 456

of signed division

by multiplication and shifting right, 273274

by summing digits, 266268

from non-powers of 2, 207210

from powers of 2, 206207

test for zero, 248251

of unsigned division

by multiplication and shifting right, 268272

by summing digits, 262266

and immediate instruction, 227

incremental division and remainder technique, 232234

test for zero, 248250

remu function, 119, 135136

Residual/residue, 324

Restoring algorithm, 192193

Reversing bits and bytes, 129137

6-, 7-, 8-, and 9-bit quantities, 135137

32-bit words, 129135

big-endian format, converting to little-endian, 129

definition, 129

generalized, 135

load word byte-reverse (lwbrx) instruction, 118

rightmost 16 bits of a word, 130

with rotate shifts, 129133

small integers, 135137

table lookup, 134

Riemann hypothesis, 404

Right justify function, 116

Rightmost bits, manipulating, 1112, 15

De Morgan‘s laws, 1213

right-to-left computability test, 1314, 55

Rijndael algorithm, 164

RISC

basic instruction set, 56

execution time model, 910

extended mnemonics, 6, 8

full instruction set, 78

registers, 56

Rotate and sum method, 8586

Rotate left function, plots and graphs, 464465

Rotate shifts, 3738, 129133

Rounding to powers of 2, 5962, 64

Ruler function, 114, 466

Russian decomposition, 51-53, 5657

S

SAG (sheep and goats) operation

description, 162165

plots and graphs, 464465

Scan operation, 97

Seal, David, 90, 110

Search tree method, 109

Searching. See Finding.

SEC (single error-correcting) codes, 331

SEC-DED (single error-correcting, double error-detecting) codes

on 32 information bits, 337342

check bits, minimum required, 335

converting from Hamming code, 334335

definition, 331

Select instruction, 406

Self-reproducing program, xvi

Self-similar triangles, plots and graphs, 460

shift left double operation, 39

shift right double signed operation, 3940

shift right double unsigned operation, 39

shift right extended immediate (shrxi) instruction, 228229

shift right signed instruction

alternative to, for sign extension, 1920

division by power of 2, 205206

from unsigned, 20

Shift-and-subtract algorithm

hardware, 192194

integer square root, 285287

Shifts

double-length, 3940

rotate, 3738

Short division, 189192, 195196

Shroeppel‘s formula, 305306

shrxi (shift right extended immediate) instruction, 228229

Shuffle Packed Bytes (PSHUFB) instruction, 163

Shuffle Packed Doublewords (PSHUFD) instruction, 163

Shuffle Packed Words (PSHUFW) instruction, 163

Shuffling

arrays, 165166

bits

half shuffle, 141

inner perfect shuffle, plots and graphs, 468469

inner perfect unshuffle, plots and graphs, 468

inner shuffle, 139141

outer shuffle, 139141, 373

perfect shuffle, 139141

shuffling bits, 139141, 165166

unshuffling, 140141, 150, 162, 165-166

Sierpinski triangle, plots and graphs, 460

Sign extension, 1920

sign function, 2021. See also three-valued compare function.

Signed bounds, 78

Signed comparisons, from unsigned, 25

Signed computer division, 181182

Signed division

arithmetic tables, 455

computer, 181

doubleword, 201202

long, 189

multiword, 188

short, 190192

Signed division of integers by constants

best programs for, 225227

by divisors ≤ –2, 218220

by divisors ≥ 2, 210218

by powers of 2, 205206

incorporating into a compiler, 220223

remainder from non-powers of 2, 207210

remainder from powers of 2, 206207

test for zero remainder, 250251

uniqueness of magic number, 224

Signed long division, 189

Signed numbers, propagating arithmetic bounds, 7173

Signed short division, 190192

signum function, 2021

Single error-correcting, double error-detecting (SEC-DED) codes. See SEC-DED (single error-correcting, double error-detecting) codes.

Single error-correcting (SEC) codes, 331

snoob function, 1415

Software checksums, 327329

Space-filling curves, 371372. See also Hilbert‘s curve.

Sparse array indexing, 95

Sphere-packing bound, 348350

Spheres, ECCs (error-correcting codes), 347350

Square root, integer

binary search, 281285

hardware algorithm, 285287

Newton‘s method, 279283

shift-and-subtract algorithm, 285287

Square root, approximate, floating-point, 389

Square root, approximate reciprocal, floating-point, 383385

Stibitz, George, 308

Strachey, Christopher, 130

Stretch computer, 81, 336

Strings. See Bit operations; Character strings.

strlen (string length) C function, 117

Subnormal numbers, 376

Subnorms, 376

subtract instruction

condition codes, 3637

propagating arithmetic bounds, 7073

Subtraction

arithmetic tables, 453

difference or zero (doz) function, 4145

double-length, 3839

combined with logical operations, 1617

multibyte, 4041

of negabinary numbers, 301302

overflow detection, 2931

plots and graphs, 461

Swap-and-complement method, 362365

Swapping pointers, 46

System/360 computer, 385

System/370 computer, 63

T

Table lookup, counting bits, 8687

three-valued compare function, 2122. See also sign function.

Tight bounds

add and subtract instructions, 7073

logical operations, 7479

Timing test, division of integers by constants, 276

Toggling among values, 4851

Tower of Hanoi puzzle, 116, 315

Trailing zeros. See also ntz (number of trailing zeros) function.

counting, 107114

detecting, 324. See also CRC (cyclic redundancy check).

plots and graphs, 466

Transfer of sign (ISIGN) function, 22

Transposing a bit matrix

8 x 8, 141145

32 x 32, 145149

Triangles

fractal, 460

plots and graphs, 460

self-similar, 460

Sierpinski, 460

Triple DES, 164

True/false comparison results, 23

Turning off 1-bits, 85

U

Ulp (unit in the last position), 378

Unaligned load, 65

Unary functions, plots and graphs, 466469

Uniqueness, of magic numbers, 224

Unshuffling

arrays, 162

bits, 140141, 162, 468

Unsigned division

arithmetic tables, 455

computer, 181

doubleword, 197201

long, 192197

short from signed, 189192

Unsigned division of integers by constants

best programs for, 234235

by 3 and 7, 227229

by divisors ≥ 1, 230232

by powers of 2, 227

incorporating into a compiler, 232234

incremental division and remainder technique, 232234

remainders, from powers of 2, 227

test for zero remainder, 248250

unsigned modulus (modu) function, 84

Unsigned product of x and y, plots and graphs, 462

Uppercase letters, finding, 122

V

Voorhies, Douglas, 373

W

Willans, C. P., 393

Willans‘s formulas, 393397

Wilson‘s theorem, 393, 403

Word parity. See Parity.

Words

counting bits, 8187

definition, 1

division

doubleword by single word, 192197

Knuth‘s Algorithm D, 184188

multiword, 184189

signed, multiword, 188

multiplication, multiword, 171173

reversing, 129134

searching for

first 0-byte, 117121

first uppercase letter, 122

strings of 1-bits, 123128

a value within a range, 122

word parallel operations, 13

Wormell, C. P., 397

Wormell‘s formula, 397398

Z

zbytel function, 117121

zbyter function, 117121

Zero means 2n, 2223

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset