"You don't know what you're talking about!" cried Humpty Dumpty. "How
many days are there in a year?"
"Three hundred and sixty-five," said Alice.
"And how many birthdays have you?"
"One."
"And if you take one from three hundred and sixty-five, what remains?"
"Three hundred and sixty-four, of course."
Humpty Dumpty looked doubtful. "I'd rather see that done on paper,"
he said.
INTERCAL provides several built-in subroutines to which control can be transferred to perform various operations. These operations include many useful functions which are not easily representable in INTERCAL, such as addition, subtraction, etc.
In general, the operands are .1
, .2
, etc.,
or :1
, :2
, etc., and the result(s) are
stored in what would have been the next operand(s). For instance, one
routine adds .1
to .2
and stores the sum in
.3
, with .4
being used to indicate overflow.
All variables not used for results are left unchanged.
At the time of this writing, only the most fundamental operations are
offered in the library, as a more complete selection would require
prohibitive time and core to implement. These functions, along with
their corresponding entry points (entered via DO
(entry) NEXT
) are listed below.
(1000)
.3
<-
.1
plus .2
, error exit on overflow
(1009)
.3
<-
.1
plus .2
.4
<- #1
if no overflow,
else .4
<- #2
(1010)
.3
<-
.1
minus .2
, no action on overflow
(1020)
.1
<-
.1
plus #1
, no action on overflow
(1030)
.3
<-
.1
times .2
, error exit on overflow
(1039)
.3
<-
.1
times .2
.4
<- #1
if no overflow,
else .4
<- #2
(1040)
.3
<-
.1
divided by .2
.3
<- #0
if
.2
is #0
(1050)
.2
<-
:1
divided by .1
, error exit on overflow
.2
<- #0
if
.1
is #0
(1500)
:3
<-
:1
plus :2
, error exit on overflow
(1509)
:3
<-
:1
plus :2
:4
<- #1
if no overflow,
else :4
<- #2
(1510)
:3
<-
:1
minus :2
, no action on overflow
(1520)
:1
<-
.1
concatenated with .2
(1525)
This subroutine is intended solely for internal
use within the subroutine library and is therefore not described here.
Its effect is to shift .3
logically 8 bits to the left.
(1530)
:1
<-
.1
times .2
(1540)
:3
<-
:1
times :2
, error exit on overflow
(1549)
:3
<-
:1
times :2
:4
<- #1
if no overflow,
else :4
<- #2
(1550)
:3
<-
:1
divided by :2
:3
<- #0
if
:2
is #0
(1900)
.1
<- uniform
random no. from #0
to #65535
(1910)
.2
<- normal random
no. from #0
to .1
, with standard deviation
.1
divided by #12
The C-INTERCAL compiler will automatically include the system library
if a DO
(1xxx) NEXT
statement is
used, and if no (1xxx) labels are defined anywhere, where
(1xxx) is a label in the 1000-1999 range, inclusive. This
was not an INTERCAL-72 feature.