================ @@ -2278,8 +2285,28 @@ void APInt::toString(SmallVectorImpl<char> &Str, unsigned Radix, bool Signed, } } else { int Pos = 0; + // The value of cutOffSize is not special, it is just a number of + // characters that gives us enough info without losing readability. + constexpr int cutOffSize = 20; while (Tmp.getBoolValue()) { uint64_t Digit; + if (truncate && Pos == cutOffSize) { + unsigned numDigits = (int32_t)(Tmp.logBase2()/log2(Radix))+1; + if(numDigits-cutOffSize > 0) { + // Calculating pow of exponents over 300000 takes a long time. + // To keep note printing time short(under 3s), values with more digits + // will only return the last 20 digits. + if(numDigits < 300000) { + APInt divider = APIntOps::pow(APInt(Tmp.getBitWidth(),Radix),numDigits-cutOffSize); + Tmp = Tmp.udiv(divider); + Str.append(3,'.'); + } + else { + Str.append(3,'.'); ---------------- erichkeane wrote:
I think that sounds like it could work? I'm not sure of the size implications... One thing to note, 'exactly 20' numbers in the 1st number isn't important. What IS important is 'enough of the first few that a couple of patterns are obvious', so the numbers have to be accurate, but the number OF them isn't important. I'm not sure I have a better idea, but I'm still thinking :) Have an attempt at the above and see if it works out. https://github.com/llvm/llvm-project/pull/145053 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits