Bug 19740 – Incorrect result of BigInt * BigInt

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-03-15T10:58:22Z
Last change time
2019-04-22T00:07:41Z
Keywords
pull
Assigned to
No Owner
Creator
shove

Comments

Comment #0 by shove — 2019-03-15T10:58:22Z
Phobos BigInt: import std.stdio; import std.bigint; void main() { BigInt a = BigInt("21564064109853809856119436871792921759477602735861860718883598889223231858251567749229246000643946915525172570414005720347114836635107318701077242428657139013586370658636861373800231155999821545535260813976141824"); BigInt b = BigInt("24803744962281995379823882491100713352172602051429295720009225462760222169497562992822776764893946374887753565629046006562280546321414491579001996466749084176426165385753291715915062443687079028833972893575179478753124157995388126623360442814982987675255286338686337769655739121672376607398141008913866162176"); writeln(a * b); } output: 534869546531112417224433204781062902761898892359096321494237754691434210354537300934260563874019540367943562659323458088415022185792973712551683566996893486557131898263986073285723729647429761218710894708286383629254677810720670377916098070892655931194710549714337100366316289037826643789354059447337922150362505288875800410103474936238316199204856442495452205694882423258214421881355757588835251714670622185442871222378657647830060162105970693118488789207481328313074989530392971574678602770081917482031044573934911488 python: import math a = 21564064109853809856119436871792921759477602735861860718883598889223231858251567749229246000643946915525172570414005720347114836635107318701077242428657139013586370658636861373800231155999821545535260813976141824 b = 24803744962281995379823882491100713352172602051429295720009225462760222169497562992822776764893946374887753565629046006562280546321414491579001996466749084176426165385753291715915062443687079028833972893575179478753124157995388126623360442814982987675255286338686337769655739121672376607398141008913866162176 print a * b output: 534869546531112417224433204781062902761898892359096321494237754691434210354537300934260563874019540367943562659323458088415022185792973712551683566996894614987401551960538578949388418152948813112659012433629094338662677449662611596957010904439288232716723045318886779000933601739621574750050993297483196659582404894095318857121844594620014537537456776720985972983385520729044161295299497108549582778848719390446798081923886686452389089223662621089753884338588229458281529170431476597180634550458389509897183526360449024
Comment #1 by shove — 2019-03-15T11:01:57Z
*** Issue 19739 has been marked as a duplicate of this issue. ***
Comment #2 by dlang-bugzilla — 2019-03-15T12:31:21Z
Comment #3 by simen.kjaras — 2019-03-15T12:59:30Z
Simpler numbers demonstrating the same issue: a = 241127122100380210001001124020210001001100000200003101000062221012075223052000021042250111300200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 b = 70020000000050041832100040114001011000002200722143200000014102001132330110410406020210020045721000160014200000101224530010000111021520000000012000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Gives this result: 20000000001000003004000000120212100201000101001104000000010101000110200200000011011012010000010401100130020000041001002003000201010011124100010007220001471870730867315477594439355311694480948106052082286667289293612000561058058780959087178453367701487987704395450321365382687298205069039303066149854725490780100394780481552981630341618301661667399665774466232711496902529170260586056260480285668935821902794996073140454770961377671072882308072028734904868893098854793460359961494977497968219623527972133861047574462464 As we can see, the result should end in a number of 0s, but most definitely doesn't. There probably are even smaller numbers that exhibit the same issue.
Comment #4 by dlang-bot — 2019-04-18T11:12:26Z
@shove70 created dlang/phobos pull request #6965 "Fix #19740: Incorrect result of BigInt * BigInt" fixing this issue: - Fixes #19740: Incorrect result of BigInt * BigInt Fix bug #19740: Incorrect result of BigInt * BigInt. https://github.com/dlang/phobos/pull/6965
Comment #5 by shove — 2019-04-20T08:08:19Z
Reposition request resubmitted: https://github.com/dlang/phobos/pull/6967
Comment #6 by shove — 2019-04-20T14:16:40Z
(In reply to shove from comment #5) > Reposition request resubmitted: > > https://github.com/dlang/phobos/pull/6967 Reposition request resubmitted: https://github.com/dlang/phobos/pull/6969
Comment #7 by apz28 — 2019-04-20T14:45:53Z
For original sample on 2019-03-15 10:58:22 UTC, .NET BigInteger gives below result. So Python seem wrong? 16883721089480688747229011802283756823349870758229387365814728471518346136944894862961035756393632618073413910091006778604956808730652275328822700182498926542563654351871390166691461743896850906716336187966456064270200717632811001335602400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Comment #8 by shove — 2019-04-22T00:07:41Z