Lines Matching full:y
192 bool BigInt::Equal(const JSTaggedValue &x, const JSTaggedValue &y) in Equal() argument
195 BigInt* yVal = BigInt::Cast(y.GetTaggedObject()); in Equal()
199 bool BigInt::Equal(const BigInt *x, const BigInt *y) in Equal() argument
202 ASSERT(y != nullptr); in Equal()
203 if (x->GetSign() != y->GetSign() || x->GetLength() != y->GetLength()) { in Equal()
207 if (x->GetDigit(i) != y->GetDigit(i)) { in Equal()
215 bool BigInt::SameValue(const JSTaggedValue &x, const JSTaggedValue &y) in SameValue() argument
217 return Equal(x, y); in SameValue()
221 bool BigInt::SameValueZero(const JSTaggedValue &x, const JSTaggedValue &y) in SameValueZero() argument
223 return Equal(x, y); in SameValueZero()
226 …dle<BigInt> BigInt::BitwiseOp(JSThread *thread, Operate op, JSHandle<BigInt> x, JSHandle<BigInt> y) in BitwiseOp() argument
231 uint32_t ylen = y->GetLength(); in BitwiseOp()
242 bigint->SetDigit(i, x->GetDigit(i) | y->GetDigit(i)); in BitwiseOp()
244 bigint->SetDigit(i, x->GetDigit(i) & y->GetDigit(i)); in BitwiseOp()
247 bigint->SetDigit(i, x->GetDigit(i) ^ y->GetDigit(i)); in BitwiseOp()
257 bigint->SetDigit(i, y->GetDigit(i)); in BitwiseOp()
264 JSHandle<BigInt> OneIsNegativeAND(JSThread *thread, JSHandle<BigInt> x, JSHandle<BigInt> y) in OneIsNegativeAND() argument
266 JSHandle<BigInt> yVal = BigInt::BitwiseSubOne(thread, y, y->GetLength()); in OneIsNegativeAND()
287 // 6.1.6.2.20 BigInt::bitwiseAND ( x, y )
288 JSHandle<BigInt> BigInt::BitwiseAND(JSThread *thread, JSHandle<BigInt> x, JSHandle<BigInt> y) in BitwiseAND() argument
290 if (x->GetSign() && y->GetSign()) { in BitwiseAND()
291 // (-x) & (-y) == -(((x-1) | (y-1)) + 1) in BitwiseAND()
293 JSHandle<BigInt> yVal = BitwiseSubOne(thread, y, y->GetLength()); in BitwiseAND()
298 if (x->GetSign() != y->GetSign()) { in BitwiseAND()
299 // x & (-y) == x & ~(y-1) in BitwiseAND()
301 return OneIsNegativeAND(thread, x, y); in BitwiseAND()
303 return OneIsNegativeAND(thread, y, x); in BitwiseAND()
306 return BitwiseOp(thread, Operate::AND, x, y); in BitwiseAND()
309 JSHandle<BigInt> OneIsNegativeXOR(JSThread *thread, JSHandle<BigInt> x, JSHandle<BigInt> y) in OneIsNegativeXOR() argument
311 JSHandle<BigInt> yVal = BigInt::BitwiseSubOne(thread, y, y->GetLength()); in OneIsNegativeXOR()
317 // 6.1.6.2.21 BigInt::bitwiseOR ( x, y )
318 JSHandle<BigInt> BigInt::BitwiseXOR(JSThread *thread, JSHandle<BigInt> x, JSHandle<BigInt> y) in BitwiseXOR() argument
320 if (x->GetSign() && y->GetSign()) { in BitwiseXOR()
321 // (-x) ^ (-y) == (x-1) ^ (y-1) in BitwiseXOR()
323 JSHandle<BigInt> yVal = BitwiseSubOne(thread, y, y->GetLength()); in BitwiseXOR()
326 if (x->GetSign() != y->GetSign()) { in BitwiseXOR()
327 // x ^ (-y) == -((x ^ (y-1)) + 1) in BitwiseXOR()
329 return OneIsNegativeXOR(thread, x, y); in BitwiseXOR()
331 return OneIsNegativeXOR(thread, y, x); in BitwiseXOR()
334 return BitwiseOp(thread, Operate::XOR, x, y); in BitwiseXOR()
385 JSHandle<BigInt> OneIsNegativeOR(JSThread *thread, JSHandle<BigInt> x, JSHandle<BigInt> y) in OneIsNegativeOR() argument
389 if (maxLen < y->GetLength()) { in OneIsNegativeOR()
390 maxLen = y->GetLength(); in OneIsNegativeOR()
392 JSHandle<BigInt> yVal = BigInt::BitwiseSubOne(thread, y, maxLen); in OneIsNegativeOR()
415 // 6.1.6.2.22 BigInt::bitwiseOR ( x, y )
416 JSHandle<BigInt> BigInt::BitwiseOR(JSThread *thread, JSHandle<BigInt> x, JSHandle<BigInt> y) in BitwiseOR() argument
418 if (x->GetSign() && y->GetSign()) { in BitwiseOR()
419 // (-x) | (-y) == -(((x-1) & (y-1)) + 1) in BitwiseOR()
421 uint32_t yLen = y->GetLength(); in BitwiseOR()
424 JSHandle<BigInt> yVal = BitwiseSubOne(thread, y, yLen); in BitwiseOR()
430 if (x->GetSign() != y->GetSign()) { in BitwiseOR()
431 // x | (-y) == -(((y-1) & ~x) + 1) in BitwiseOR()
433 return OneIsNegativeOR(thread, x, y); in BitwiseOR()
435 return OneIsNegativeOR(thread, y, x); in BitwiseOR()
438 return BitwiseOp(thread, Operate::OR, x, y); in BitwiseOR()
620 JSHandle<BigInt> BigInt::Add(JSThread *thread, JSHandle<BigInt> x, JSHandle<BigInt> y) in Add() argument
623 bool ySignFlag = y->GetSign(); in Add()
624 // x + y == x + y in Add()
625 // -x + -y == -(x + y) in Add()
627 return BigintAdd(thread, x, y, xSignFlag); in Add()
629 // x + -y == x - y == -(y - x) in Add()
630 // -x + y == y - x == -(x - y) in Add()
632 uint32_t yLength = y->GetLength(); in Add()
636 return BigintSub(thread, x, y, xSignFlag); in Add()
638 while (i > 0 && x->GetDigit(i) == y->GetDigit(i)) { in Add()
641 if ((x->GetDigit(i) > y->GetDigit(i))) { in Add()
642 return BigintSub(thread, x, y, xSignFlag); in Add()
644 return BigintSub(thread, y, x, ySignFlag); in Add()
647 return BigintSub(thread, y, x, ySignFlag); in Add()
650 JSHandle<BigInt> BigInt::Subtract(JSThread *thread, JSHandle<BigInt> x, JSHandle<BigInt> y) in Subtract() argument
653 bool ySignFlag = y->GetSign(); in Subtract()
655 // x - (-y) == x + y in Subtract()
656 // (-x) - y == -(x + y) in Subtract()
657 return BigintAdd(thread, x, y, xSignFlag); in Subtract()
659 // x - y == -(y - x) in Subtract()
660 // (-x) - (-y) == y - x == -(x - y) in Subtract()
662 uint32_t yLength = y->GetLength(); in Subtract()
666 return BigintSub(thread, x, y, xSignFlag); in Subtract()
668 while (i > 0 && x->GetDigit(i) == y->GetDigit(i)) { in Subtract()
671 if ((x->GetDigit(i) > y->GetDigit(i))) { in Subtract()
672 return BigintSub(thread, x, y, xSignFlag); in Subtract()
674 return BigintSub(thread, y, x, !ySignFlag); in Subtract()
677 return BigintSub(thread, y, x, !ySignFlag); in Subtract()
681 JSHandle<BigInt> BigInt::BigintAdd(JSThread *thread, JSHandle<BigInt> x, JSHandle<BigInt> y, bool r… in BigintAdd() argument
683 if (x->GetLength() < y->GetLength()) { in BigintAdd()
684 return BigintAdd(thread, y, x, resultSign); in BigintAdd()
689 while (i < y->GetLength()) { in BigintAdd()
691 uint32_t addPlus = BigIntHelper::AddHelper(x->GetDigit(i), y->GetDigit(i), newBigintCarry); in BigintAdd()
709 inline uint32_t BigIntHelper::AddHelper(uint32_t x, uint32_t y, uint32_t &bigintCarry) in AddHelper() argument
711 uint32_t addPlus = x + y; in AddHelper()
718 JSHandle<BigInt> BigInt::BigintSub(JSThread *thread, JSHandle<BigInt> x, JSHandle<BigInt> y, bool r… in BigintSub() argument
723 while (i < y->GetLength()) { in BigintSub()
725 uint32_t minuSub = BigIntHelper::SubHelper(x->GetDigit(i), y->GetDigit(i), newBigintCarry); in BigintSub()
754 inline uint32_t BigIntHelper::SubHelper(uint32_t x, uint32_t y, uint32_t &bigintCarry) in SubHelper() argument
756 uint32_t minuSub = x - y; in SubHelper()
763 ComparisonResult BigInt::Compare(const JSTaggedValue &x, const JSTaggedValue &y) in Compare() argument
766 BigInt* yVal = BigInt::Cast(y.GetTaggedObject()); in Compare()
770 ComparisonResult BigInt::Compare(const BigInt *x, const BigInt *y) in Compare() argument
773 bool ySign = y->GetSign(); in Compare()
777 ComparisonResult compar = AbsolutelyCompare(x, y); in Compare()
784 bool BigInt::LessThan(const JSTaggedValue &x, const JSTaggedValue &y) in LessThan() argument
786 return Compare(x, y) == ComparisonResult::LESS; in LessThan()
789 bool BigInt::LessThan(const BigInt *x, const BigInt *y) in LessThan() argument
792 ASSERT(y != nullptr); in LessThan()
793 return Compare(x, y) == ComparisonResult::LESS; in LessThan()
796 JSHandle<BigInt> BigInt::SignedRightShift(JSThread *thread, JSHandle<BigInt> x, JSHandle<BigInt> y) in SignedRightShift() argument
799 bool yIsNull = y->GetDigit(0); in SignedRightShift()
803 if (y->GetSign()) { in SignedRightShift()
804 return LeftShiftHelper(thread, x, y); in SignedRightShift()
806 return RightShiftHelper(thread, x, y); in SignedRightShift()
862 JSHandle<BigInt> BigInt::RightShiftHelper(JSThread *thread, JSHandle<BigInt> x, JSHandle<BigInt> y) in RightShiftHelper() argument
865 if (y->GetLength() > 1 || y->GetDigit(0) > MAXBITS) { in RightShiftHelper()
868 uint32_t moveNum = y->GetDigit(0); in RightShiftHelper()
894 JSHandle<BigInt> BigInt::LeftShift(JSThread *thread, JSHandle<BigInt> x, JSHandle<BigInt> y) in LeftShift() argument
896 if (y->GetSign()) { in LeftShift()
897 return RightShiftHelper(thread, x, y); in LeftShift()
899 return LeftShiftHelper(thread, x, y); in LeftShift()
903 JSHandle<BigInt> BigInt::LeftShiftHelper(JSThread *thread, JSHandle<BigInt> x, JSHandle<BigInt> y) in LeftShiftHelper() argument
905 ASSERT(y->GetLength() == 1); in LeftShiftHelper()
906 ASSERT(y->GetDigit(0) <= MAXBITS); in LeftShiftHelper()
907 uint32_t moveNum = y->GetDigit(0); in LeftShiftHelper()
958 JSHandle<BigInt> y = Copy(thread, x, x->GetLength()); in UnaryMinus() local
959 y->SetSign(!y->GetSign()); in UnaryMinus()
960 return y; in UnaryMinus()
1027 std::tuple<uint32_t, uint32_t> BigInt::Mul(uint32_t x, uint32_t y) in Mul() argument
1031 uint32_t lowBitY = y & HALFDATEMASK; in Mul()
1032 uint32_t highBitY = y >> HALFDATEBITS; in Mul()
1047 JSHandle<BigInt> BigInt::Multiply(JSThread *thread, JSHandle<BigInt> x, JSHandle<BigInt> y) in Multiply() argument
1052 if (y->IsZero()) { in Multiply()
1053 return y; in Multiply()
1055 uint32_t needLength = x->GetLength() + y->GetLength(); in Multiply()
1071 for (uint32_t j = 0; j < y->GetLength(); j++) { in Multiply()
1078 std::tie(high, low) = Mul(xVal, y->GetDigit(j)); in Multiply()
1097 bigint->SetSign(x->GetSign() != y->GetSign()); in Multiply()
1114 ComparisonResult BigInt::AbsolutelyCompare(const BigInt *x, const BigInt *y) in AbsolutelyCompare() argument
1117 uint32_t yLen = y->GetLength(); in AbsolutelyCompare()
1125 if (x->GetDigit(index) != y->GetDigit(index)) { in AbsolutelyCompare()
1132 … return x->GetDigit(index) > y->GetDigit(index) ? ComparisonResult::GREAT : ComparisonResult::LESS; in AbsolutelyCompare()
1360 JSHandle<BigInt> BigInt::Divide(JSThread *thread, JSHandle<BigInt> x, JSHandle<BigInt> y) in Divide() argument
1362 if (y->IsZero()) { in Divide()
1366 // returns 0 if x is less than y in Divide()
1368 bool sign = x->GetSign() != y->GetSign(); in Divide()
1369 ComparisonResult compare = AbsolutelyCompare(*x, *y); in Divide()
1378 // if y is 1, return +x or -x in Divide()
1379 if (y->IsUint32() && y->GetDigit(0) == 1) { in Divide()
1386 if (y->IsUint32()) { in Divide()
1388 quotient.Update(DivideAndRemainderWithUint32Divisor(thread, x, y->GetDigit(0), remainder)); in Divide()
1390 … ASSERT(y->GetLength() >= 1); // 1 : Entering the current branch length must be greater than 1 in Divide()
1391 quotient.Update(DivideAndRemainderWithBigintDivisor(thread, x, y, remainder)); in Divide()