[Issue 19740] New: Incorrect result of BigInt * BigInt

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Mar 15 10:58:22 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=19740

          Issue ID: 19740
           Summary: Incorrect result of BigInt * BigInt
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: shove at 163.com

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

--


More information about the Digitalmars-d-bugs mailing list