large number division

Discussions related to Visual Prolog
drspro2
VIP Member
Posts: 78
Joined: 28 Apr 2006 12:03

large number division

Unread post by drspro2 » 9 Jun 2016 10:06

hello,

i would need to compute this:

271011240123456789232100 / 97 = 2793930310551100919918,5567010309278351


--- the real and the unsigned64 is too small for this,

maybe anyone know a suggestion of how to do this,

thankyou

drspro2
VIP Member
Posts: 78
Joined: 28 Apr 2006 12:03

Unread post by drspro2 » 9 Jun 2016 13:11

i already found de solution, here is my code

Code: Select all

get_fro_without_zero(Bigs,Le,Bg,Bigs_rs):-  string::tryfront(Bigs,5,Sta,Rs), Sta = "00000",  string::tryfront(Rs,Le,Bg,Bigs_rs),!.   get_fro_without_zero(Bigs,Le,Bg,Bigs_rs):-  string::tryfront(Bigs,4,Sta,Rs), Sta = "0000",  string::tryfront(Rs,Le,Bg,Bigs_rs),!.   get_fro_without_zero(Bigs,Le,Bg,Bigs_rs):-  string::tryfront(Bigs,3,Sta,Rs), Sta = "000",  string::tryfront(Rs,Le,Bg,Bigs_rs),!.   get_fro_without_zero(Bigs,Le,Bg,Bigs_rs):-  string::tryfront(Bigs,2,Sta,Rs), Sta = "00",  string::tryfront(Rs,Le,Bg,Bigs_rs),!.   get_fro_without_zero(Bigs,Le,Bg,Bigs_rs):-  string::tryfront(Bigs,1,Sta,Rs), Sta = "0",  string::tryfront(Rs,Le,Bg,Bigs_rs),!.   get_fro_without_zero(Bigs,Le,Bg,Bigs_rs):-  string::tryfront(Bigs,Le,Bg,Bigs_rs),!.     %---   front_dividable(Bigs,Tal,Bg,Rem,Bigs_rs):-  Leta = string::length(toString(Tal)),  %string::tryfront(Bigs,Leta,Bg,Bigs_rs),  get_fro_without_zero(Bigs,Leta,Bg,Bigs_rs),  X = tryToTerm(integer,Bg),  Divi = X / Tal,  Y = math::trunc(Divi),  Y > 0,!,  Rem = X - (Y * Tal).   front_dividable(Bigs,Tal,Bg,Rem,Bigs_rs):-  Leta = string::length(toString(Tal)),  get_fro_without_zero(Bigs,Leta + 1,Bg,Bigs_rs),    X = tryToTerm(integer,Bg),  Divi = X / Tal,  Y = math::trunc(Divi),  Y > 0,!,  Rem = X - (Y * Tal).   %-- remainder_self(Tal,Bigs,RemaS):-  front_dividable(Bigs,Tal,_Bgxx,Remain,Bigs_rs),!,  Bigs_rs2 = string::concat(toString(Remain),Bigs_rs),  remainder_self(Tal,Bigs_rs2,RemaS).   remainder_self(_Tal,Rem,Rem):- !.

Post Reply