Nullstone Logo

COMPANY
Home
Contacts
Customers
Testimonials

PRODUCTS
Overview
NULLSTONE for C
NULLSTONE for Java
Technical Overview

SUPPORT
Release Notes
Download
PGP Information
Service Report
Write Us

INFORMATION
Performance Results
Glossary of Terms

RELATED LINKS
Compiler Connection
Compiler Jobs

Previous Up Next
Narrowing

The limited dynamic range of small integers can be used to simplify some expressions, even if the value of the small integer is not known.

Example:

Each of the expressions in the code fragments below can be replaced with the value zero (on systems that define short to have 16 bits).

    unsigned short int s;
    
    (s >> 20)      /* all bits of precision have been shifted out, thus 0 */
    (s > 0x10000)  /* 16 bit value can't be greater than 17 bit, thus 0 */
    (s == -1)      /* can't be negative, thus 0 */
    

Notes:

This type of expression may indicate an error in the program, and some compilers emit warnings for some of these expressions (e.g. unsigned short compared to a negative constant).

Programmers generally don't write these expressions directly. However, these expressions can occur after macro expansion, or after other optimizations.

© 1990-2012 Nullstone Corporation. All Rights Reserved.