Vault 7: Projects

This publication series is about specific projects related to the Vault 7 main publication.

MPLAB
®
XC16 C COMPILER
USERS GUIDE
2012-2013 Microchip Technology Inc. DS50002071C-page 139
Chapter 9. Fixed-Point Arithmetic Support
9.1 INTRODUCTION
The MPLAB XC16 C compiler supports fixed-point arithmetic according to the N1169
draft of ISO/IEC TR 18037, the ISO C99 technical report on Embedded C, available
here:
http://www.open-std.org/JTC1/SC22/WG14/www/projects#18037
This appendix describes the implementation-specific details of the types and opera-
tions supported by the compiler under this draft standard.
Enabling Fixed-Point Arithmetic Support
Data Types
Rounding
External Definitions
Mixing C and Assembly Language Code
9.2 ENABLING FIXED-POINT ARITHMETIC SUPPORT
Fixed-point arithmetic support is not enabled by default in the MPLAB XC16 C com-
piler; it must be explicitly enabled by the -menable-fixed compiler switch, described
in Section 5.7 Driver Option Descriptions.
9.3 DATA TYPES
All 12 of the primary fixed-point types and their aliases, described in section 4.1 Over-
view and principles of the fixed-point data types of N1169, are supported via three
fixed point formats corresponding to the intrinsic hardware capabilities of Microchip
16-bit devices.
These formats represent the fixed-point C data types, shown below.
TABLE 9-1: FIXED POINT FORMATS - 16-BIT DEVICES
Format Description
1.15 1 bit sign, 15 bits fraction
1.31 1 bit sign, 31 bits fraction
9.31 9 bit signed integer, 31 bits fraction
TABLE 9-2: FIXED POINT FORMATS - C DATA TYPES
Type Format
_Fract 1.15
short _Fract 1.15
signed _Fract 1.15
signed short _Fract 1.15
unsigned _Fract 1.15 (sign bit 0)
unsigned short _Fract 1.15 (sign bit 0)
long _Fract 1.31

e-Highlighter

Click to send permalink to address bar, or right-click to copy permalink.

Un-highlight all Un-highlight selectionu Highlight selectionh