Page **1** of **1**

### Giant constant numbers.

Posted: **7 Aug 2017 15:26**

by **kingchris**

If I am doing some odd maths how does one get large numbers into integer64 variables and constants.

There is a unsigned64:value function I think that takes two parameters.

One of my constants is 80 characters for I might have to call a 128 bit library.

In C and C++ one always added a L to the end of your number constant.

unsigned var = 7362398263876L;

I believe that C++ 11 has 128 bit numbers now.

Cheers

###

Posted: **7 Aug 2017 19:24**

by **Thomas Linder Puls**

I do not think there are 128 bit numbers (by default) in C++ 11, but it is not something I know for sure.

However, the 'L' in C/C++ literals indicates a 64 bit number.

I Visual Prolog you can use the types

**unsigned64** and

**integer64** and you do not need to use any special marks to write such numbers:

Code: Select all

constants
value : unsigned64 = 7362398263876.
class predicates
p : (unsigned64 X) -> unsigned64 Y.
clauses
p(X) = 7362398263876 + value + X.

unsigned64 have the range [0..18446744073709551615].

integer64 have the range [-9223372036854775808..9223372036854775807].

128 bit numbers cannot hold a 80 digit number, the largest number in an 128 bit unsigned is 2^128 ~ 3,4e38 (i.e. 39 digits).

A real can hold very large numbers, but (only) with ~15 digits precision.

###

Posted: **7 Aug 2017 23:47**

by **Martin Meyer**

Hello Chris (and Thomas and all),

the below attached project gives an example how one could deal with numbers which exceed the limits of the build-in number domains. The example implements large unsigned integer numbers encoded in binaries. The implemented arithmetics uses however only the -simple- school methods. For multiplication and especially for division faster (but more complicated) algorithms are known.

###

Posted: **8 Aug 2017 5:54**

by **kingchris**

Thanks gentlemen for your assistance.

Much appreciated