Floating-Point Extensions for C — Part 1: Binary Floating-Point Arithmetic
Total Page:16
File Type:pdf, Size:1020Kb
© ISO/IEC 2013 – All rights reserved Draft Technical Specification – November 5, 2013 ISO/IEC JTC 1/SC 22/WG 14 N1778 Date: yyyy-mm-dd Reference number of document: ISO/IEC TS 18661-1 5 Committee identification: ISO/IEC JTC 1/SC 22/WG 14 Secretariat: ANSI Information Technology — Programming languages, their environments, and system software interfaces — Floating-point extensions for C — Part 1: Binary floating-point arithmetic 10 Technologies de l’information — Langages de programmation, leurs environnements et interfaces du logiciel système — Extensions à virgule flottante pour C — Partie I: Binaire arithmétique flottante Warning This document is not an ISO International Standard. It is distributed for review and comment. It is subject to 15 change without notice and may not be referred to as an International Standard. Recipients of this draft are invited to submit, with their comments, notification of any relevant patent rights of which they are aware and to provide supporting documentation. Document type: Technical Specification Document subtype: Document stage: (20) Preparation Document language: E ISO/IEC TS 18661-1 Draft Technical Specification – November 5, 2013 WG 14 N1778 Copyright notice This ISO document is a working draft or committee draft and is copyright-protected by ISO. While the reproduction of working drafts or committee drafts in any form for use by participants in the ISO standards development process is permitted without prior permission from ISO, neither this document 5 nor any extract from it may be reproduced, stored or transmitted in any form for any other purpose without prior written permission from ISO. Requests for permission to reproduce this document for the purpose of selling it should be addressed as shown below or to ISO’s member body in the country of the requester: ISO copyright office 10 Case postale 56 CH-1211 Geneva 20 Tel. +41 22 749 01 11 Fax + 41 22 749 09 47 E-mail [email protected] Web www.iso.org 15 Reproduction for sales purposes may be subject to royalty payments or a licensing agreement. Violators may be prosecuted. ii © ISO/IEC 2013 – All rights reserved WG 14 N1778 Draft Technical Specification – November 5, 2013 ISO/IEC TS 18661-1 Contents Page Introduction ....................................................................................................................................................... v! Background ................................................................................................................................................... v! IEC 60559 floating-point standard ........................................................................................................... v! 5 C support for IEC 60559 ........................................................................................................................... vi! Purpose ........................................................................................................................................................ vii! 1! Scope ........................................................................................................................................................... 1! 2! Conformance ............................................................................................................................................... 1! 3! Normative references ................................................................................................................................. 1! 10 4! Terms and definitions ................................................................................................................................. 1! 5! C standard conformance ............................................................................................................................ 2! 5.1! Freestanding implementations ............................................................................................................... 2! 5.2! Predefined macros ................................................................................................................................... 2! 5.3! Standard headers ..................................................................................................................................... 3! 15 6! Revised floating-point standard ................................................................................................................ 5! 7! Types ............................................................................................................................................................ 6! 7.1! Terminology ............................................................................................................................................. 6! 7.2! Canonical representation ........................................................................................................................ 7! 8! Operation binding ....................................................................................................................................... 8! 20 9! Floating to integer conversion ................................................................................................................ 13! 10! Conversions between floating types and character sequences ........................................................ 13! 10.1! Conversions with decimal character sequences .............................................................................. 13! 10.2! Conversions to character sequences ................................................................................................ 14! 11! Constant rounding directions ................................................................................................................ 15! 25 12! NaN support ............................................................................................................................................ 22! 13! Integer width macros .............................................................................................................................. 27! 14! Mathematics <math.h> .......................................................................................................................... 29! 14.1! Nearest integer functions .................................................................................................................... 29! 14.1.1! Round to integer value in floating type ............................................................................................ 29! 30 14.1.2! Convert to integer type ...................................................................................................................... 31! 14.2! The llogb functions ............................................................................................................................ 34! 14.3! Max-min magnitude functions ............................................................................................................ 35! 14.4! The nextup and nextdown functions ................................................................................................ 36! 14.5! Functions that round result to narrower type ................................................................................... 37! 35 14.6! Comparison macros ............................................................................................................................ 40! 14.7! Classification macros .......................................................................................................................... 41! 14.8! Total order functions ........................................................................................................................... 43! 14.9! Canonicalize functions ........................................................................................................................ 44! 14.10! NaN functions ..................................................................................................................................... 45! 40 15! The floating-point environment <fenv.h> ........................................................................................... 47! 15.1! The fesetexcept function ................................................................................................................. 47! 15.2! The fetestexceptflag function ...................................................................................................... 48! 15.3! Control modes ...................................................................................................................................... 48! 16! Type-generic math <tgmath.h> ........................................................................................................... 50! 45 Bibliography .................................................................................................................................................... 52! © ISO/IEC 2013 – All rights reserved iii ISO/IEC TS 18661-1 Draft Technical Specification – November 5, 2013 WG 14 N1778 Foreword ISO (the International Organization for Standardization) is a worldwide federation of national standards bodies (ISO member bodies). The work of preparing International Standards is normally carried out through ISO technical committees. Each member body interested in a subject for which a technical committee has been 5 established has the right to be represented on that committee. International organizations, governmental and non-governmental, in liaison with ISO, also