icon Top 9 categories map      RocketAware > Perl >

Integer Arithmetic

Tips: Browse or Search all pages for efficient awareness of Perl functions, operators, and FAQs.



Home

Search Perl pages


Subjects

By activity
Professions, Sciences, Humanities, Business, ...

User Interface
Text-based, GUI, Audio, Video, Keyboards, Mouse, Images,...

Text Strings
Conversions, tests, processing, manipulation,...

Math
Integer, Floating point, Matrix, Statistics, Boolean, ...

Processing
Algorithms, Memory, Process control, Debugging, ...

Stored Data
Data storage, Integrity, Encryption, Compression, ...

Communications
Networks, protocols, Interprocess, Remote, Client Server, ...

Hard World
Timing, Calendar and Clock, Audio, Video, Printer, Controls...

File System
Management, Filtering, File & Directory access, Viewers, ...

    

Integer Arithmetic

By default Perl assumes that it must do most of its arithmetic in floating point. But by saying

    use integer;

you may tell the compiler that it's okay to use integer operations from here to the end of the enclosing BLOCK. An inner BLOCK may countermand this by saying

    no integer;

which lasts until the end of that BLOCK.

The bitwise operators (``&'', ``|'', ``^'', ``~'', ``<<``, and ''>>``) always produce integral results. However, use integer still has meaning for them. By default, their results are interpreted as unsigned integers. However, if use integer is in effect, their results are interpreted as signed integers. For example, ~0 usually evaluates to a large integral value. However, use integer; ~0 is -1.


Source: Perl operators and precedence
Copyright: Larry Wall, et al.
Next: Floating-point Arithmetic

Previous: Constant Folding



(Corrections, notes, and links courtesy of RocketAware.com)


[Overview Topics]

Up to: Integer math




Rapid-Links: Search | About | Comments | Submit Path: RocketAware > Perl > perlop/Integer_Arithmetic.htm
RocketAware.com is a service of Mib Software
Copyright 2000, Forrest J. Cavalier III. All Rights Reserved.
We welcome submissions and comments