#!/usr/bin/perl -l #Program to calculate the range of unsigned integer numbers #produced from 1 to 32 bits. use warnings; use strict; for(0..32){ my $bin='0b'.'1'x$_; print "$_ : 0 to ",oct $bin; } #### #include #include main () { long int i=1,j=i; /* title */ puts("Bits\tRange"); puts("----\t-----"); /* O/P data and calc the next * set of values */ for (i=1; i<=32; i++) { printf("%2ld\t0-%12lu\n", i, j*=2); } } #### for(31..64){ #### Binary number > 0b11111111111111111111111111111111 non-portable at ./bits line 11 #### Integer overflow in binary number at ./bits line 12 (#1) (W overflow) The hexadecimal, octal or binary number you have specified either as a literal or as an argument to hex() or oct() is too big for your architecture, and has been converted to a floating point number. On a 32-bit architecture the largest hexadecimal, octal or binary number representable without overflow is 0xFFFFFFFF, 037777777777, or 0b11111111111111111111111111111111 respectively. Note that Perl transparently promotes all numbers to a floating point representation internally--subject to loss of precision errors in subsequent operations. #### Binary number > 0b11111111111111111111111111111111 non-portable at ./bits line 12 (#2) (W portable) The binary number you specified is larger than 2**32-1 (4294967295) and therefore non-portable between systems. See perlport for more on portability concerns.