<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--Rendered using the Haskell Html Library v0.2--> <HTML ><HEAD ><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8" ><TITLE >Data.Int</TITLE ><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css" ><SCRIPT SRC="haddock-util.js" TYPE="text/javascript" ></SCRIPT ><SCRIPT TYPE="text/javascript" >window.onload = function () {setSynopsis("mini_Data-Int.html")};</SCRIPT ></HEAD ><BODY ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="topbar" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD ><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" " ></TD ><TD CLASS="title" >base-4.1.0.0: Basic libraries</TD ><TD CLASS="topbut" ><A HREF="index.html" >Contents</A ></TD ><TD CLASS="topbut" ><A HREF="doc-index.html" >Index</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="modulebar" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD ><FONT SIZE="6" >Data.Int</FONT ></TD ><TD ALIGN="right" ><TABLE CLASS="narrow" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="infohead" >Portability</TD ><TD CLASS="infoval" >portable</TD ></TR ><TR ><TD CLASS="infohead" >Stability</TD ><TD CLASS="infoval" >experimental</TD ></TR ><TR ><TD CLASS="infohead" >Maintainer</TD ><TD CLASS="infoval" >libraries@haskell.org</TD ></TR ></TABLE ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="section4" ><B >Contents</B ></TD ></TR ><TR ><TD ><DL ><DT ><A HREF="#1" >Signed integer types </A ></DT ><DT ><A HREF="#2" >Notes </A ></DT ></DL ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" >Description</TD ></TR ><TR ><TD CLASS="doc" >Signed integer types </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" >Synopsis</TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="../ghc-prim/GHC-Types.html#t%3AInt" >Int</A > (<A HREF="../ghc-prim/GHC-Types.html#v%3AI%23" >I#</A >)</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3AInt8" >Int8</A > </TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3AInt16" >Int16</A > </TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3AInt32" >Int32</A > </TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3AInt64" >Int64</A > </TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" ><A NAME="1" ><A NAME="1" >Signed integer types </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="../ghc-prim/GHC-Types.html#t%3AInt" >Int</A > (<A HREF="../ghc-prim/GHC-Types.html#v%3AI%23" >I#</A >)</TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:Int8" ><A NAME="t%3AInt8" ></A ></A ><B >Int8</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" >8-bit signed integer type </TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Int8')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:Int8" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Prelude.html#t%3ABounded" >Bounded</A > <A HREF="Data-Int.html#t%3AInt8" >Int8</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Prelude.html#t%3AEnum" >Enum</A > <A HREF="Data-Int.html#t%3AInt8" >Int8</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Eq.html#t%3AEq" >Eq</A > <A HREF="Data-Int.html#t%3AInt8" >Int8</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Prelude.html#t%3AIntegral" >Integral</A > <A HREF="Data-Int.html#t%3AInt8" >Int8</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Data.html#t%3AData" >Data</A > <A HREF="Data-Int.html#t%3AInt8" >Int8</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Prelude.html#t%3ANum" >Num</A > <A HREF="Data-Int.html#t%3AInt8" >Int8</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Ord.html#t%3AOrd" >Ord</A > <A HREF="Data-Int.html#t%3AInt8" >Int8</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Text-Read.html#t%3ARead" >Read</A > <A HREF="Data-Int.html#t%3AInt8" >Int8</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Prelude.html#t%3AReal" >Real</A > <A HREF="Data-Int.html#t%3AInt8" >Int8</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Text-Show.html#t%3AShow" >Show</A > <A HREF="Data-Int.html#t%3AInt8" >Int8</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="GHC-Arr.html#t%3AIx" >Ix</A > <A HREF="Data-Int.html#t%3AInt8" >Int8</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > <A HREF="Data-Int.html#t%3AInt8" >Int8</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Bits.html#t%3ABits" >Bits</A > <A HREF="Data-Int.html#t%3AInt8" >Int8</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Foreign-Storable.html#t%3AStorable" >Storable</A > <A HREF="Data-Int.html#t%3AInt8" >Int8</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Text-Printf.html#t%3APrintfArg" >PrintfArg</A > <A HREF="Data-Int.html#t%3AInt8" >Int8</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:Int16" ><A NAME="t%3AInt16" ></A ></A ><B >Int16</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" >16-bit signed integer type </TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Int16')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:Int16" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Prelude.html#t%3ABounded" >Bounded</A > <A HREF="Data-Int.html#t%3AInt16" >Int16</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Prelude.html#t%3AEnum" >Enum</A > <A HREF="Data-Int.html#t%3AInt16" >Int16</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Eq.html#t%3AEq" >Eq</A > <A HREF="Data-Int.html#t%3AInt16" >Int16</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Prelude.html#t%3AIntegral" >Integral</A > <A HREF="Data-Int.html#t%3AInt16" >Int16</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Data.html#t%3AData" >Data</A > <A HREF="Data-Int.html#t%3AInt16" >Int16</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Prelude.html#t%3ANum" >Num</A > <A HREF="Data-Int.html#t%3AInt16" >Int16</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Ord.html#t%3AOrd" >Ord</A > <A HREF="Data-Int.html#t%3AInt16" >Int16</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Text-Read.html#t%3ARead" >Read</A > <A HREF="Data-Int.html#t%3AInt16" >Int16</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Prelude.html#t%3AReal" >Real</A > <A HREF="Data-Int.html#t%3AInt16" >Int16</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Text-Show.html#t%3AShow" >Show</A > <A HREF="Data-Int.html#t%3AInt16" >Int16</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="GHC-Arr.html#t%3AIx" >Ix</A > <A HREF="Data-Int.html#t%3AInt16" >Int16</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > <A HREF="Data-Int.html#t%3AInt16" >Int16</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Bits.html#t%3ABits" >Bits</A > <A HREF="Data-Int.html#t%3AInt16" >Int16</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Foreign-Storable.html#t%3AStorable" >Storable</A > <A HREF="Data-Int.html#t%3AInt16" >Int16</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Text-Printf.html#t%3APrintfArg" >PrintfArg</A > <A HREF="Data-Int.html#t%3AInt16" >Int16</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:Int32" ><A NAME="t%3AInt32" ></A ></A ><B >Int32</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" >32-bit signed integer type </TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Int32')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:Int32" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Prelude.html#t%3ABounded" >Bounded</A > <A HREF="Data-Int.html#t%3AInt32" >Int32</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Prelude.html#t%3AEnum" >Enum</A > <A HREF="Data-Int.html#t%3AInt32" >Int32</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Eq.html#t%3AEq" >Eq</A > <A HREF="Data-Int.html#t%3AInt32" >Int32</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Prelude.html#t%3AIntegral" >Integral</A > <A HREF="Data-Int.html#t%3AInt32" >Int32</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Data.html#t%3AData" >Data</A > <A HREF="Data-Int.html#t%3AInt32" >Int32</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Prelude.html#t%3ANum" >Num</A > <A HREF="Data-Int.html#t%3AInt32" >Int32</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Ord.html#t%3AOrd" >Ord</A > <A HREF="Data-Int.html#t%3AInt32" >Int32</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Text-Read.html#t%3ARead" >Read</A > <A HREF="Data-Int.html#t%3AInt32" >Int32</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Prelude.html#t%3AReal" >Real</A > <A HREF="Data-Int.html#t%3AInt32" >Int32</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Text-Show.html#t%3AShow" >Show</A > <A HREF="Data-Int.html#t%3AInt32" >Int32</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="GHC-Arr.html#t%3AIx" >Ix</A > <A HREF="Data-Int.html#t%3AInt32" >Int32</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > <A HREF="Data-Int.html#t%3AInt32" >Int32</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Bits.html#t%3ABits" >Bits</A > <A HREF="Data-Int.html#t%3AInt32" >Int32</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Foreign-Storable.html#t%3AStorable" >Storable</A > <A HREF="Data-Int.html#t%3AInt32" >Int32</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Text-Printf.html#t%3APrintfArg" >PrintfArg</A > <A HREF="Data-Int.html#t%3AInt32" >Int32</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:Int64" ><A NAME="t%3AInt64" ></A ></A ><B >Int64</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" >64-bit signed integer type </TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Int64')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:Int64" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Prelude.html#t%3ABounded" >Bounded</A > <A HREF="Data-Int.html#t%3AInt64" >Int64</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Prelude.html#t%3AEnum" >Enum</A > <A HREF="Data-Int.html#t%3AInt64" >Int64</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Eq.html#t%3AEq" >Eq</A > <A HREF="Data-Int.html#t%3AInt64" >Int64</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Prelude.html#t%3AIntegral" >Integral</A > <A HREF="Data-Int.html#t%3AInt64" >Int64</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Data.html#t%3AData" >Data</A > <A HREF="Data-Int.html#t%3AInt64" >Int64</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Prelude.html#t%3ANum" >Num</A > <A HREF="Data-Int.html#t%3AInt64" >Int64</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Ord.html#t%3AOrd" >Ord</A > <A HREF="Data-Int.html#t%3AInt64" >Int64</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Text-Read.html#t%3ARead" >Read</A > <A HREF="Data-Int.html#t%3AInt64" >Int64</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Prelude.html#t%3AReal" >Real</A > <A HREF="Data-Int.html#t%3AInt64" >Int64</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Text-Show.html#t%3AShow" >Show</A > <A HREF="Data-Int.html#t%3AInt64" >Int64</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="GHC-Arr.html#t%3AIx" >Ix</A > <A HREF="Data-Int.html#t%3AInt64" >Int64</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > <A HREF="Data-Int.html#t%3AInt64" >Int64</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Bits.html#t%3ABits" >Bits</A > <A HREF="Data-Int.html#t%3AInt64" >Int64</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Foreign-Storable.html#t%3AStorable" >Storable</A > <A HREF="Data-Int.html#t%3AInt64" >Int64</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Text-Printf.html#t%3APrintfArg" >PrintfArg</A > <A HREF="Data-Int.html#t%3AInt64" >Int64</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" ><A NAME="2" ><A NAME="2" >Notes </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="doc" ><UL ><LI > All arithmetic is performed modulo 2^n, where <TT >n</TT > is the number of bits in the type. </LI ><LI > For coercing between any two integer types, use Prelude.fromIntegral, which is specialized for all the common cases so should be fast enough. Coercing word types (see <A HREF="Data-Word.html" >Data.Word</A >) to and from integer types preserves representation, not sign. </LI ><LI > The rules that hold for Prelude.Enum instances over a bounded type such as <TT ><A HREF="../ghc-prim/GHC-Types.html#t%3AInt" >Int</A ></TT > (see the section of the Haskell report dealing with arithmetic sequences) also hold for the Prelude.Enum instances over the various <TT ><A HREF="../ghc-prim/GHC-Types.html#t%3AInt" >Int</A ></TT > types defined here. </LI ><LI > Right and left shifts by amounts greater than or equal to the width of the type result in either zero or -1, depending on the sign of the value being shifted. This is contrary to the behaviour in C, which is undefined; a common interpretation is to truncate the shift count to the width of the type, for example <TT >1 << 32 == 1</TT > in some C implementations. </LI ></UL ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="botbar" >Produced by <A HREF="http://www.haskell.org/haddock/" >Haddock</A > version 2.4.2</TD ></TR ></TABLE ></BODY ></HTML >