src/swipl-devel/packages/xpce/man/refmanual/md/number.md

class number {#class-number}

A number object represents an integer just like the primitive type int. Numbers are more costly, but allow for some operations such as comparison or addition.

Instances of class number are commonly used to implement counters:

count_instances(Device, Class, Instances) :-
    new(I, number(0)),
    send(Device, for_all, @default,
         if(message(@arg1, instance_of, Class),
            message(I, plus, 1))),
    get(I, value, Instances),
    send(I, done).

See also class real.

@see class binary_expression @see pce<-max_integer

Instance variables {#class-number-instvars}

Send methods {#class-number-send}

Get methods {#class-number-get}



Try the rswipl package in your browser

Any scripts or data that you put into this service are public.

rswipl documentation built on June 16, 2026, 5:07 p.m.