digitalmars.D.bugs - [Issue 19739] New: Incorrect result of (BigInt * BigInt) % BigInt
- d-bugmail puremagic.com (40/40) Mar 15 2019 https://issues.dlang.org/show_bug.cgi?id=19739
https://issues.dlang.org/show_bug.cgi?id=19739 Issue ID: 19739 Summary: Incorrect result of (BigInt * BigInt) % BigInt Product: D Version: D2 Hardware: x86 OS: Mac OS X Status: NEW Severity: enhancement Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: shove 163.com Phobos BigInt: import std.stdio; import std.bigint; void main() { BigInt a = BigInt("21564064109853809856119436871792921759477602735861860718883598889223231858251567749229246000643946915525172570414005720347114836635107318701077242428657139013586370658636861373800231155999821545535260813976141824"); BigInt b = BigInt("24803744962281995379823882491100713352172602051429295720009225462760222169497562992822776764893946374887753565629046006562280546321414491579001996466749084176426165385753291715915062443687079028833972893575179478753124157995388126623360442814982987675255286338686337769655739121672376607398141008913866162176"); BigInt c = BigInt("15592449738095488747095865752434291846961185542216220364759273981537092410281077438681696466616075686558177072453373402338707270142067490009719653528419587472581511984462717336534941668232441962559088176638497609044546648097927645721037778102973426356054296888813806902955798744299849144156358264329743948114764184416762788718214428905372552136684197402848523489807177325912904135652219542981709775375540339611246490836320016382720250825185957794383439798883449063066374895720135846683755238373327764428067892090073454994927125784245547852359595514868496354506574119550798838256819273440775635200380478117288464985161"); writeln((a * b) % c); } output: 534869546531112417224433204781062902761898892359096321494237754691434210354537300934260563874019540367943562659323458088415022185792973712551683566996893486557131898263986073285723729647429761218710894708286383629254677810720670377916098070892655931194710549714337100366316289037826643789354059447337922150362505288875800410103474936238316199204856442495452205694882423258214421881355757588835251714670622185442871222378657647830060162105970693118488789207481328313074989530392971574678602770081917482031044573934911488 python: import math a = 21564064109853809856119436871792921759477602735861860718883598889223231858251567749229246000643946915525172570414005720347114836635107318701077242428657139013586370658636861373800231155999821545535260813976141824 b = 24803744962281995379823882491100713352172602051429295720009225462760222169497562992822776764893946374887753565629046006562280546321414491579001996466749084176426165385753291715915062443687079028833972893575179478753124157995388126623360442814982987675255286338686337769655739121672376607398141008913866162176 c = 15592449738095488747095865752434291846961185542216220364759273981537092410281077438681696466616075686558177072453373402338707270142067490009719653528419587472581511984462717336534941668232441962559088176638497609044546648097927645721037778102973426356054296888813806902955798744299849144156358264329743948114764184416762788718214428905372552136684197402848523489807177325912904135652219542981709775375540339611246490836320016382720250825185957794383439798883449063066374895720135846683755238373327764428067892090073454994927125784245547852359595514868496354506574119550798838256819273440775635200380478117288464985161 print (a * b) % c output: 534869546531112417224433204781062902761898892359096321494237754691434210354537300934260563874019540367943562659323458088415022185792973712551683566996894614987401551960538578949388418152948813112659012433629094338662677449662611596957010904439288232716723045318886779000933601739621574750050993297483196659582404894095318857121844594620014537537456776720985972983385520729044161295299497108549582778848719390446798081923886686452389089223662621089753884338588229458281529170431476597180634550458389509897183526360449024 --
Mar 15 2019