← Inside Macintosh: PowerPC Numerics

Inside Macintosh: PowerPC Numerics

From the originals

13 scans

Machine-transcribed text and image descriptions. Check the linked original for uncertain words or fine print.

These are transcribed pages from the documents, not the full publications. Open the original for the remaining pages.

Image 1

INSIDE MACINTOSH PowerPC Numerics Addison-Wesley Publishing Company Reading, Massachusetts Menlo Park, California New York Don Mills, Ontario Wokingham, England Amsterdam Bonn Sydney Singapore Tokyo Madrid San Juan Paris Seoul Milan Mexico City Taipei

A plain white title page with an Apple logo at top, the spaced-out title INSIDE MACINTOSH, a horizontal rule, the large subtitle PowerPC Numerics, and a publisher's emblem with the Addison-Wesley Publishing Company imprint and office city list at the bottom.

Reading notes: The small publisher emblem above the imprint name is a graphic and not transcribed as text. Reading order of the city list follows visual line layout.

Languages
English
PDF page 1

Addison-Wesley Publishing Company Reading, Massachusetts Menlo Park, California New York Don Mills, Ontario Wokingham, England Amsterdam Bonn Sydney Singapore Tokyo Madrid San Juan Paris Seoul Milan Mexico City Taipei I N S I D E M A C I N T O S H PowerPC Numerics

Reading notes: Transcript is intentionally empty because the exact extracted text is preserved separately. Headline is taken from the letter-spaced title line; exact line breaks and spacing were not verified against the image. Publisher office locations are listed in multiple lines and their visual arrangement was not verified against the image. The book title PowerPC Numerics is not treated as an advertised product because the supplied copy shows it as a title, not a sales offer.

Languages
English
PDF page 2

Apple Computer, Inc. © 1994 Apple Computer, Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, mechanical, electronic, photocopying, recording, or otherwise, without prior written permission of Apple Computer, Inc. Printed in the United States of America. No licenses, express or implied, are granted with respect to any of the technology described in this book. Apple retains all intellectual property rights associated with the technology described in this book. This book is intended to assist application developers to develop applications only for Apple Macintosh computers. Every effort has been made to ensure that the information in this manual is accurate. Apple is not responsible for printing or clerical errors. Apple Computer, Inc. 20525 Mariani Avenue Cupertino, CA 95014 408-996-1010 Apple, the Apple logo, LaserWriter, and Macintosh are trademarks of Apple Computer, Inc., registered in the United States and other countries. PowerPC is a trademark of International Business Machines Corporation. Adobe Illustrator, Adobe Photoshop, and PostScript are trademarks of Adobe Systems Incorporated, which may be registered in certain jurisdictions. FrameMaker is a registered trademark of Frame Technology Corporation. Helvetica and Palatino are registered trademarks of Linotype Company. ITC Zapf Dingbats is a registered trademark of International Typeface Corporation. Optrotech is a trademark of Orbotech Corporation. Simultaneously published in the United States and Canada. LIMITED WARRANTY ON MEDIA AND REPLACEMENT ALL IMPLIED WARRANTIES ON THIS MANUAL, INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE LIMITED IN DURATION TO NINETY (90) DAYS FROM THE DATE OF THE ORIGINAL RETAIL PURCHASE OF THIS PRODUCT. Even though Apple has reviewed this manual, APPLE MAKES NO WARRANTY OR REPRESENTATION, EITHER EXPRESS OR IMPLIED, WITH RESPECT TO THIS MANUAL, ITS QUALITY, ACCURACY, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. AS A RESULT, THIS MANUAL IS SOLD “AS IS,” AND YOU, THE PURCHASER, ARE ASSUMING THE ENTIRE RISK AS TO ITS QUALITY AND ACCURACY. IN NO EVENT WILL APPLE BE LIABLE FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES RESULTING FROM ANY DEFECT OR INACCURACY IN THIS MANUAL, even if advised of the possibility of such damages. THE WARRANTY AND REMEDIES SET FORTH ABOVE ARE EXCLUSIVE AND IN LIEU OF ALL OTHERS, ORAL OR WRITTEN, EXPRESS OR IMPLIED. No Apple dealer, agent, or employee is authorized to make any modification, extension, or addition to this warranty. Some states do not allow the exclusion or limitation of implied warranties or liability for incidental or consequential damages, so the above limitation or exclusion may not apply to you. This warranty gives you specific legal rights, and you may also have other rights which vary from state to state. ISBN 0-201-40728-0 1 2 3 4 5 6 7 8 9-CRW-9897969594 First Printing, March 1994 Library of Congress Cataloging-in-Publication Data Book_title / [Apple Computer, Inc.]. p. cm. Includes index. ISBN 0-201-nnnnn-n 1. Macintosh (Computer)—Programming. 2. I. Apple Computer, Inc. nnnn.n.nnnnnnn 1994 nnn.nnn—nnnn 94-nnnnn CIP

Reading notes: Transcript is intentionally empty because the exact extracted text is preserved separately. The page is a legal and copyright notice rather than an advertisement, so the product names are trademark mentions and not advertised products. Macintosh and LaserWriter appear as trademarks in the supplied copy; no advertised prices appear. The Library of Congress CIP block contains placeholder fragments (nnnn, nnn) and the ISBN 0-201-nnnnn-n is partly unfilled, so those spans are unreliable. Reading order and column layout of the original page could not be confirmed from the supplied text.

Printed product names
LaserWriter · Macintosh
Printed dates
© 1994 · March 1994 · 1994
Languages
English
PDF page 3

iii Contents Figures, Tables, and Listings xi Preface About This Book xvii What’s in This Book xviii Conventions Used in This Book xviii Special Fonts xix Types of Notes xix For More Information xix Part One The PowerPC Numerics Environment Chapter 1 IEEE Standard Arithmetic 1-1 About the IEEE Standard 1-3 Starting to Use IEEE Arithmetic 1-5 Careful Rounding 1-5 Exception Handling 1-6 Example: Finding Zero Return Values 1-7 Example: Searching Without Stopping 1-8 Example: Parallel Resistances 1-8 Using IEEE Arithmetic 1-9 Evaluating Continued Fractions 1-9 Computing the Area of a Triangle 1-11 About the FPCE Technical Report 1-12 PowerPC Numerics Versus SANE 1-13 Chapter 2 Floating-Point Data Formats 2-1 About Floating-Point Data Formats 2-3 Interpreting Floating-Point Values 2-4 Normalized Numbers 2-5 Denormalized Numbers 2-6 Infinities 2-7 NaNs 2-8 Zeros 2-10

Languages
English
PDF page 4

iv Formats 2-11 Single Format 2-11 Double Format 2-13 Double-Double Format 2-14 Range and Precision of Data Formats 2-16 Chapter 3 Expression Evaluation 3-1 About Expression Evaluation 3-3 Evaluating Expressions Without Widest Need 3-3 Evaluating Expressions With Widest Need 3-5 Comparisons of Expression Evaluation Methods 3-8 Chapter 4 Environmental Controls 4-1 Rounding Direction Modes 4-3 Rounding Precision 4-4 Exception Flags 4-4 Invalid Operation 4-5 Underflow 4-5 Overflow 4-5 Divide-by-Zero 4-6 Inexact 4-6 Chapter 5 Conversions 5-1 About Conversions 5-3 Converting Floating-Point to Integer Formats 5-3 Rounding Floating-Point Numbers to Integers 5-4 Converting Integers to Floating-Point Formats 5-5 Converting Between Floating-Point Formats 5-5 Converting Between Single and Double Formats 5-5 Converting Between Single and Double-Double Formats 5-5 Converting Between Double and Double-Double Formats 5-7 Converting Between Binary and Decimal Numbers 5-7 Accuracy of Decimal-to-Binary Conversions 5-7 Automatic Conversions 5-8 Manual Conversions 5-10 Converting Between Floating-Point and Decimal Structures 5-10 Converting Between Floating-Point and Decimal Strings 5-12

Languages
English
PDF page 5

v Chapter 6 Numeric Operations and Functions 6-1 Comparisons 6-3 Comparisons With NaNs and Infinities 6-3 Comparison Operators 6-3 Arithmetic Operations 6-5 Auxiliary Functions 6-14 Transcendental Functions 6-15 Part Two The PowerPC Numerics C Implementation Chapter 7 Numeric Data Types in C 7-1 C Data Types 7-3 Efficient Type Declarations 7-3 Inquiries: Class and Sign 7-4 Creating Infinities and NaNs 7-5 Numeric Data Types Summary 7-6 C Summary 7-6 Constants 7-6 Data Types 7-7 Special Value Routines and Macros 7-7 Chapter 8 Environmental Control Functions 8-1 Controlling the Rounding Direction 8-3 Controlling the Exception Flags 8-5 Accessing the Floating-Point Environment 8-9 Environmental Controls Summary 8-14 C Summary 8-14 Constants 8-14 Data Types 8-14 Environment Access Routines 8-15 Chapter 9 Conversion Functions 9-1 Converting Floating-Point to Integer Formats 9-3 Rounding Floating-Point Numbers to Integers 9-6 Converting Integers to Floating-Point Formats 9-12 Converting Between Floating-Point Formats 9-13 Converting Between Binary and Decimal Numbers 9-13

Reading notes: Source appears to be a table of contents rather than advertising copy; headline taken from first chapter heading as printed.

Languages
English
PDF page 6

vi Converting Between Decimal Formats 9-19 Conversions Summary 9-24 C Summary 9-24 Constants 9-24 Data Types 9-24 Conversion Routines 9-25 Chapter 10 Transcendental Functions 10-1 Comparison Functions 10-3 Sign Manipulation Functions 10-9 Exponential Functions 10-12 Logarithmic Functions 10-20 Logarithmic Functions 10-23 Trigonometric Functions 10-29 Hyperbolic Functions 10-39 Financial Functions 10-46 Error and Gamma Functions 10-51 Miscellaneous Functions 10-56 Transcendental Functions Summary 10-61 C Summary 10-61 Constants 10-61 Data Types 10-61 Transcendental Functions 10-61 Part Three Numerics in PowerPC Assembly Language Chapter 11 Introduction to Assembly-Language Numerics 11-1 PowerPC Floating-Point Architecture 11-3 Floating-Point Data Formats 11-3 Floating-Point Registers 11-3 Floating-Point Special-Purpose Registers 11-4 The Machine State Register 11-4 Floating-Point Instructions 11-4 Load and Store Instructions 11-5 Numerics Example Using PowerPC Assembly Language 11-7

Reading notes: The source is a table of contents rather than advertising copy, so no headline, products, prices, or dates are identifiable. Page numbers and entries may be misaligned with their chapter headings in the extracted text.

Languages
English
PDF page 7

Chapter 12 Assembly-Language Environmental Controls

vii Chapter 12 Assembly-Language Environmental Controls 12-1 The Floating-Point Environment 12-3 The Floating-Point Status and Control Register 12-3 The Condition Register 12-5 Inquiries: Class and Sign 12-7 Floating-Point Result Flags and Condition Codes 12-7 Example: Determining Class 12-8 Setting the Rounding Direction 12-9 Floating-Point Exceptions 12-10 Exception Bits in the FPSCR 12-10 Signaling and Clearing Floating-Point Exceptions 12-11 Enabling and Disabling Floating-Point Exceptions 12-12 Testing for Floating-Point Exceptions 12-12 Saving and Restoring the Floating-Point Environment 12-14 Chapter 13 Assembly-Language Numeric Conversions 13-1 Conversions From Integer to Floating-Point Formats 13-3 Conversions From Floating-Point to Integer Formats 13-4 Conversions From Single to Double Format 13-5 Conversions From Double to Single Format 13-5 Chapter 14 Assembly-Language Numeric Operations 14-1 Comparison Operations 14-3 Arithmetic Operations 14-4 Arithmetic Instructions 14-4 Multiply-Add Instructions 14-6 Move Instructions 14-7 Transcendental and Auxiliary Functions 14-8 Appendix A SANE Versus PowerPC Numerics A-1 Comparison of SANE and PowerPC Numerics A-1 Floating-Point Data Formats A-1 Conversions A-1 Expression Evaluation A-2 Infinities, NaNs, and Denormalized Numbers A-2 Arithmetic and Comparison Operations A-2 Environmental Controls A-3 Transcendental (Elementary) Functions A-3 Porting SANE to PowerPC Numerics A-3 Replacing Variables of Type comp A-4

Languages
English
PDF page 8

Appendix B Porting Programs to PowerPC Numerics

viii Using MathLib Instead of the SANE Library A-4 Replacing Extended Format Variables A-5 Using MathLib Functions A-5 Differences in Transcendental Functions A-5 Differences in Class and Sign Inquiries A-6 Differences in Environmental Controls A-7 Compatibility Tools in MathLib A-9 Portable Declarations A-9 Macros A-10 Appendix B Porting Programs to PowerPC Numerics B-1 Semantics of Arithmetic Evaluation B-1 Mixed Formats B-2 Floating-Point Precision B-2 The Rules of Evaluation B-2 The Invalid Exception B-3 Appendix C MathLib Header Files C-1 Floating-Point Header File (fp.h) C-1 Constants C-1 Inquiry Macros C-2 Data Types C-3 Functions C-4 Trigonometric Functions C-4 Hyperbolic Functions C-5 Exponential Functions C-5 Power and Absolute Value Functions C-7 Gamma and Error Functions C-7 Nearest Integer Functions C-8 Remainder Functions C-9 Auxiliary Functions C-9 Maximum, Minimum, and Positive Difference Functions C-9 Internal Prototypes C-10 Non-NCEG Extensions C-10 Floating-Point Environment Header File (fenv.h) C-12 Constants C-12 Floating-Point Exception Flags C-12 Rounding Direction Modes C-12 Data Types C-13 Functions C-13 Controlling the Floating-Point Exceptions C-13 Controlling the Rounding Direction C-13 Controlling the Floating-Point Environment C-13

Languages
English
PDF page 9

ix Appendix D FPCE Recommendations for Compilers D-1 Environmental Access Switch D-1 Contraction Operator Switch D-2 Hexadecimal Floating-Point Constants D-3 Implementing an Expression Evaluation Method D-3 Expression Evaluation Without Widest Need D-4 Expression Evaluation With Widest Need D-5 Floating-Point Constant Evaluation D-5 Initializing Floating-Point Objects D-7 Compiler Extensions for Expression Evaluation D-8 Determining the Expression Evaluation Method D-8 Widening for Efficiency D-8 Appendix E MathLib Reference E-1 Floating-Point Data Formats E-1 Environmental Controls E-2 Operations and Functions E-3 PowerPC Assembly-Language Numerics Appendix F Reference F-1 Floating-Point Data Formats F-1 Floating-Point Status and Control Register F-2 Instructions F-4 Glossary GL-1 Bibliography BI-1 Index IN-1

Reading notes: Source is a table of contents fragment with page references; no headline or advertised content present.

Languages
English
PDF page 10

The image is an entirely blank white page with no visible artwork, text, or layout elements.

Reading notes: No visible text appears anywhere on the page, so the transcript and printed fields are empty.

PDF page 11

xi Figures, Tables, and Listings Chapter 1 IEEE Standard Arithmetic 1-1 Figure 1-1 Parallel resistances 1-9 Figure 1-2 Graph of continued fraction functions cf( x ) and rf( x ) 1-10 Table 1-1 Approximation of real numbers 1-4 Table 1-2 Area using Heron’s formula 1-11 Listing 1-1 Inverse operations 1-6 Chapter 2 Floating-Point Data Formats 2-1 Figure 2-1 IEEE single format 2-3 Figure 2-2 Normalized single-precision numbers on the number line 2-5 Figure 2-3 Denormalized single-precision numbers on the number line 2-6 Figure 2-4 Infinities represented in single precision 2-8 Figure 2-5 NaNs represented in single precision 2-10 Figure 2-6 Zeros represented in single precision 2-11 Figure 2-7 Single format 2-12 Figure 2-8 Single-format floating-point numbers on the real number line 2-12 Figure 2-9 Double format 2-13 Figure 2-10 Double-format floating-point values on the real number line 2-14 Figure 2-11 Double-double format 2-14 Figure 2-12 Double-double format number example 2-15 Table 2-1 Names of data types 2-4 Table 2-2 Example of gradual underflow 2-7 Table 2-3 NaN codes 2-9 Table 2-4 Symbols used in format diagrams 2-11 Table 2-5 Values of single-format numbers (32 bits) 2-12 Table 2-6 Values of double-format numbers (64 bits) 2-13 Table 2-7 Summary of PowerPC Numerics data formats 2-16 Chapter 3 Expression Evaluation 3-1 Figure 3-1 Evaluating complex expressions without widest need 3-5 Figure 3-2 Evaluating complex expressions with widest need 3-7 Figure 3-3 Evaluating an expression with a function call 3-9 Figure 3-4 Evaluating an expression with arithmetic operations 3-10

Languages
English