This commit is contained in:
Ingy döt Net 2013-10-27 22:24:23 +00:00
parent 6f050a029e
commit 776bba907c
3887 changed files with 59894 additions and 7280 deletions

View file

@ -0,0 +1,4 @@
42 // a decimal integer
#x2A // a hexadecimal integer
#o52 // an octal integer
#b101010 // a binary integer

View file

@ -0,0 +1,11 @@
:- object(integers).
:- public(show/0).
show :-
write('Binary 0b11110101101 = '), write(0b11110101101), nl,
write('Octal 0o3655 = '), write(0o3655), nl,
write('Decimal 1965 = '), write(1965), nl,
write('Hexadecimal 0x7AD = '), write(0x7AD), nl.
:- end_object.

View file

@ -0,0 +1,6 @@
| ?- integers::show.
Binary 0b11110101101 = 1965
Octal 0o3655 = 1965
Decimal 1965 = 1965
Hexadecimal 0x7AD = 1965
yes

View file

@ -0,0 +1,2 @@
> 11
ans = 11

View file

@ -0,0 +1,2 @@
> 0x11
ans = 17

View file

@ -0,0 +1,3 @@
hex2dec(s)
bin2dec(s)
base2dec(s,base)

View file

@ -0,0 +1,8 @@
int8(8)
uint8(8)
int16(8)
uint16(8)
int32(8)
uint32(8)
int64(8)
uint64(8)

View file

@ -0,0 +1,11 @@
42 // integer literal
1_000_000 // _ can be used for readability
1_42_00 // or unreadability...
0x2a // hexadecimal integer literal
0o52 // octal integer literal
0b101010 // binary integer literal
10u // unsigned int
10b, 10sb, 10bs // signed byte
10ub, 10bu // unsigned byte
10L // long
10UL, 10LU // unsigned long