thousands - Thousands separator for large integers
:- use_module(library(thousands)).
main :-
Seconds is 32 * 365 * n(86,400),
Seconds =:= n(1,009,152,000),
format('32 years in seconds: ~D~n', [n(1,009,152,000)]).
A Prolog macro for specifying large numbers with a thousands separator. For example, instead of writing this:
format('32 years in seconds: ~D~n', [1009152000]).
One can write this
format('32 years in seconds: ~D~n', [n(1,009,152,000)]).
The extra commas help one visually parse the number and its relative magnitude.
Using SWI-Prolog 6.3 or later:
$ swipl
1 ?- pack_install(thousands).
| thousands.pl | ||
|---|---|---|
| n/2 | Represents an integer less than 1 million. | |
| n/3 | Represents an integer less than 1 billion. | |
| n/4 | Represents an integer less than 1 trillion. | |