FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log inLog in 


Giant constant numbers.

Post new topic   Reply to topic    discuss.visual-prolog.com Forum Index -> Visual Prolog
View previous topic :: View next topic  
Author Message
kingchris




Joined: 26 Sep 2005
Posts: 56

PostPosted: 7 Aug 2017 15:26    Post subject: Giant constant numbers. Reply with quote

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
Back to top
View user's profile Send private message
Thomas Linder Puls



Copenhagen, Denmark
Joined: 28 Feb 2000
Posts: 3124

PostPosted: 7 Aug 2017 19:24    Post subject: Reply with quote

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:


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.

_________________
Regards Thomas Linder Puls
Prolog Development Center
Back to top
View user's profile Send private message
Martin Meyer



Frankfurt a.M., Germany
Joined: 14 Nov 2002
Posts: 223

PostPosted: 7 Aug 2017 23:47    Post subject: Reply with quote

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.



bigUnsigned.zip
 Description:

Download
 Filename:  bigUnsigned.zip
 Filesize:  12.24 KB
 Downloaded:  13 Time(s)


_________________
Regards Martin
Back to top
View user's profile Send private message
kingchris




Joined: 26 Sep 2005
Posts: 56

PostPosted: 8 Aug 2017 5:54    Post subject: Reply with quote

Thanks gentlemen for your assistance.

Much appreciated
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    discuss.visual-prolog.com Forum Index -> Visual Prolog All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum