Apr-22-2018, 08:17 AM
(This post was last modified: Apr-22-2018, 08:19 AM by Gribouillis.)
(Apr-22-2018, 07:39 AM)Pleiades Wrote: OverflowError: int too large to convert to floatYou need the floating type
mpmath.mpf
. The following computation may be correct (read the doc!)>>> import mpmath as mp >>> mp.mp.dps = 1000 >>> mp.mp.prec 3325 >>> x = mp.mpf(3**1279) >>> x mpf('17301541007910038054176056432452867095149043770336183739760994896914962855011729112692135469308113595623662446442598795834444897233706143344824357701420610156423345105638078275879693218333055393875886226458620734496461814517152992352402982745998689203987491576943864064210130929012975963553401138869026447532834194444684876122440822192338479455455335994013248316240321358466758500551665434276274478532775337486153362645579799959393898179890245190220628605618273528084601403702463029225950540686613177600948606835157545386013111476205803857649578582946755008105822347197520438156375214337925994262260644194653867.0') >>> x % mp.mpf('19.1') mpf('10.19999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999986211221154848220654005392902057139770156790286166144188800371401237452170538589543598035521683264914310586337686699894347939024860146540757548385574874504630831265632890197664535441563639513497048756683543708442778829491602757769872393215591581152938167421054163471394836743703044131001404204016205461841021455948652709053963994607698563023642172696945794949806477041895118333497516253529717948650209753919929653496184540071834200082524982267781226809556415809041082332587896492941756602172886446388115227194726605314781134096334203545572724145359345153758473917409997845778716764066425820393664286016039105526')You can do it without mpmath, using only integers:
>>> (3**1279*10) % 191 102