Lines Matching full:llong
512 LLAssert(llong(llong::kD32).asDouble() == llong::kD32);
515 LLAssert(llong(0, 1).asDouble() == 1);
516 LLAssert(llong(1, 0).asDouble() == llong::kD32);
517 LLAssert(llong((uint32_t)-1, (uint32_t)-1).asDouble() == -1);
520 LLAssert(llong().asDouble() == 0);
523 LLAssert(llong((int32_t)0).asInt() == (int32_t)0);
524 LLAssert(llong((int32_t)1).asInt() == (int32_t)1);
525 LLAssert(llong((int32_t)-1).asInt() == (int32_t)-1);
526 LLAssert(llong((int32_t)0x7fffffff).asInt() == (int32_t)0x7fffffff);
527 LLAssert(llong((int32_t)0xffffffff).asInt() == (int32_t)-1);
528 LLAssert(llong((int32_t)0x80000000).asInt() == (int32_t)0x80000000);
531 LLAssert(llong((int16_t)0).asInt() == (int16_t)0);
532 LLAssert(llong((int16_t)1).asInt() == (int16_t)1);
533 LLAssert(llong((int16_t)-1).asInt() == (int16_t)-1);
534 LLAssert(llong((int16_t)0x7fff).asInt() == (int16_t)0x7fff);
535 LLAssert(llong((int16_t)0xffff).asInt() == (int16_t)0xffff);
536 LLAssert(llong((int16_t)0x8000).asInt() == (int16_t)0x8000);
539 LLAssert(llong((int8_t)0).asInt() == (int8_t)0);
540 LLAssert(llong((int8_t)1).asInt() == (int8_t)1);
541 LLAssert(llong((int8_t)-1).asInt() == (int8_t)-1);
542 LLAssert(llong((int8_t)0x7f).asInt() == (int8_t)0x7f);
543 LLAssert(llong((int8_t)0xff).asInt() == (int8_t)0xff);
544 LLAssert(llong((int8_t)0x80).asInt() == (int8_t)0x80);
547 LLAssert(llong((uint16_t)0).asUInt() == (uint16_t)0);
548 LLAssert(llong((uint16_t)1).asUInt() == (uint16_t)1);
549 LLAssert(llong((uint16_t)-1).asUInt() == (uint16_t)-1);
550 LLAssert(llong((uint16_t)0x7fff).asUInt() == (uint16_t)0x7fff);
551 LLAssert(llong((uint16_t)0xffff).asUInt() == (uint16_t)0xffff);
552 LLAssert(llong((uint16_t)0x8000).asUInt() == (uint16_t)0x8000);
555 LLAssert(llong((uint32_t)0).asUInt() == (uint32_t)0);
556 LLAssert(llong((uint32_t)1).asUInt() == (uint32_t)1);
557 LLAssert(llong((uint32_t)-1).asUInt() == (uint32_t)-1);
558 LLAssert(llong((uint32_t)0x7fffffff).asUInt() == (uint32_t)0x7fffffff);
559 LLAssert(llong((uint32_t)0xffffffff).asUInt() == (uint32_t)-1);
560 LLAssert(llong((uint32_t)0x80000000).asUInt() == (uint32_t)0x80000000);
563 LLAssert(llong((double)0).asDouble() == (double)0);
564 LLAssert(llong((double)1).asDouble() == (double)1);
565 LLAssert(llong((double)0x7fffffff).asDouble() == (double)0x7fffffff);
566 LLAssert(llong((double)0x80000000).asDouble() == (double)0x80000000);
567 LLAssert(llong((double)0x80000001).asDouble() == (double)0x80000001);
570 double maxmantissa = (llong((int32_t)1) << 40).asDouble();
571 LLAssert(llong(maxmantissa).asDouble() == maxmantissa);
572 LLAssert(llong(-maxmantissa).asDouble() == -maxmantissa);
575 LLAssert(llong(llong(0, 1)).asDouble() == 1);
576 LLAssert(llong(llong(1, 0)).asDouble() == llong::kD32);
577 LLAssert(llong(llong(-1, (uint32_t)-1)).asDouble() == -1);
580 LLAssert(llong((uint32_t)-1).asInt() == (int32_t)0x7fffffff);
581 LLAssert(llong(-1, 0).asInt() == (int32_t)0x80000000);
584 LLAssert(llong((int32_t)-1).asUInt() == (uint32_t)-1);
585 LLAssert(llong((int32_t)0x80000000).asUInt() == (uint32_t)0x80000000);
596 LLAssert(llong() == llong(0, 0));
597 LLAssert(llong(1,0) == llong(1, 0));
598 LLAssert(llong(0,1) == llong(0, 1));
601 LLAssert(llong(1,0) != llong(1,1));
602 LLAssert(llong(0,1) != llong(1,1));
603 LLAssert(llong(0xffffffff,0xffffffff) != llong(0x7fffffff, 0xffffffff));
606 LLAssert(llong((int32_t)-1).ugt(llong(0x7fffffff, 0xffffffff)));
609 LLAssert(llong(0x7fffffff, 0xffffffff).ult(llong((int32_t)-1)));
612 LLAssert(llong((int32_t)-1).uge(llong(0x7fffffff, 0xffffffff)));
613 LLAssert(llong((int32_t)-1).uge(llong((int32_t)-1)));
616 LLAssert(llong(0x7fffffff, 0xffffffff).ule(llong((int32_t)-1)));
617 LLAssert(llong((int32_t)-1).ule(llong((int32_t)-1)));
620 LLAssert(llong(1, 1) > llong(1, 0));
621 LLAssert(llong(0, 0x80000000) > llong(0, 0x7fffffff));
622 LLAssert(llong(0x80000000, 1) > llong(0x80000000, 0));
623 LLAssert(llong(1, 0) > llong(0, 0x7fffffff));
624 LLAssert(llong(1, 0) > llong(0, 0xffffffff));
625 LLAssert(llong(0, 0) > llong(0x80000000, 1));
628 LLAssert(llong(1, 0) < llong(1, 1));
629 LLAssert(llong(0, 0x7fffffff) < llong(0, 0x80000000));
630 LLAssert(llong(0x80000000, 0) < llong(0x80000000, 1));
631 LLAssert(llong(0, 0x7fffffff) < llong(1, 0));
632 LLAssert(llong(0, 0xffffffff) < llong(1, 0));
633 LLAssert(llong(0x80000000, 1) < llong(0, 0));
636 LLAssert(llong(1, 1) >= llong(1, 0));
637 LLAssert(llong(0, 0x80000000) >= llong(0, 0x7fffffff));
638 LLAssert(llong(0x80000000, 1) >= llong(0x80000000, 0));
639 LLAssert(llong(1, 0) >= llong(0, 0x7fffffff));
640 LLAssert(llong(1, 0) >= llong(0, 0xffffffff));
641 LLAssert(llong(0, 0) >= llong(0x80000000, 1));
642 LLAssert(llong() >= llong(0, 0));
643 LLAssert(llong(1,0) >= llong(1, 0));
644 LLAssert(llong(0,1) >= llong(0, 1));
647 LLAssert(llong(1, 0) <= llong(1, 1));
648 LLAssert(llong(0, 0x7fffffff) <= llong(0, 0x80000000));
649 LLAssert(llong(0x80000000, 0) <= llong(0x80000000, 1));
650 LLAssert(llong(0, 0x7fffffff) <= llong(1, 0));
651 LLAssert(llong(0, 0xffffffff) <= llong(1, 0));
652 LLAssert(llong(0x80000000, 1) <= llong(0, 0));
653 LLAssert(llong() <= llong(0, 0));
654 LLAssert(llong(1,0) <= llong(1, 0));
655 LLAssert(llong(0,1) <= llong(0, 1));
658 LLAssert(llong() == (int32_t)0);
659 LLAssert(llong(0,1) == (int32_t)1);
662 LLAssert(llong(1,0) != (int32_t)0);
663 LLAssert(llong(0,1) != (int32_t)2);
664 LLAssert(llong(0,0xffffffff) != (int32_t)-1);
666 llong negOne(0xffffffff, 0xffffffff);
669 LLAssert(llong(0, 0x80000000) > (int32_t)0x7fffffff);
671 LLAssert(llong(1, 0) > (int32_t)0x7fffffff);
672 LLAssert(llong(0, 0) > (int32_t)-1);
675 LLAssert(llong(0, 0x7ffffffe) < (int32_t)0x7fffffff);
676 LLAssert(llong(0xffffffff, 0xfffffffe) < (int32_t)-1);
679 LLAssert(llong(0, 0x80000000) >= (int32_t)0x7fffffff);
681 LLAssert(llong(1, 0) >= (int32_t)0x7fffffff);
682 LLAssert(llong(0, 0) >= (int32_t)-1);
683 LLAssert(llong() >= (int32_t)0);
684 LLAssert(llong(0,1) >= (int32_t)1);
687 LLAssert(llong(0, 0x7ffffffe) <= (int32_t)0x7fffffff);
688 LLAssert(llong(0xffffffff, 0xfffffffe) <= (int32_t)-1);
689 LLAssert(llong() <= (int32_t)0);
690 LLAssert(llong(0,1) <= (int32_t)1);
693 LLAssert((llong(2,3) = llong((uint32_t)-1)).asUInt() == (uint32_t)-1);
696 LLAssert((llong(1, 1) <<= 0) == llong(1, 1));
697 LLAssert((llong(1, 1) <<= 31) == llong(0x80000000, 0x80000000));
698 LLAssert((llong(1, 1) <<= 32) == llong(1, 0));
699 LLAssert((llong(1, 1) <<= 63) == llong(0x80000000, 0));
700 LLAssert((llong(1, 1) <<= 64) == llong(1, 1)); // only lower 6 bits are used
701 LLAssert((llong(1, 1) <<= -1) == llong(0x80000000, 0)); // only lower 6 bits are used
704 LLAssert((llong((int32_t)1) << 5).asUInt() == 32);
707 LLAssert((llong(0x7fffa0a0, 0xbcbcdfdf) >>= 16) == llong(0x7fff,0xa0a0bcbc));
708 LLAssert((llong(0x8000789a, 0xbcde0000) >>= 16) == llong(0xffff8000,0x789abcde));
709 LLAssert((llong(0x80000000, 0) >>= 63) == llong(0xffffffff, 0xffffffff));
710 LLAssert((llong(0x80000000, 0) >>= 47) == llong(0xffffffff, 0xffff0000));
711 LLAssert((llong(0x80000000, 0x80000000) >> 64) == llong(0x80000000, 0x80000000)); // only lower 6 bits are used
712 LLAssert((llong(0x80000000, 0) >>= -1) == llong(0xffffffff, 0xffffffff)); // only lower 6 bits are used
715 LLAssert((llong(0x8000789a, 0xbcde0000) >> 16) == llong(0xffff8000,0x789abcde));
718 LLAssert(llong(0x7fffa0a0, 0xbcbcdfdf).ushr(16) == llong(0x7fff,0xa0a0bcbc));
719 LLAssert(llong(0x8000789a, 0xbcde0000).ushr(16) == llong(0x00008000,0x789abcde));
720 LLAssert(llong(0x80000000, 0).ushr(63) == llong(0, 1));
721 LLAssert(llong(0x80000000, 0).ushr(47) == llong(0, 0x10000));
722 LLAssert(llong(0x80000000, 0x80000000).ushr(64) == llong(0x80000000, 0x80000000)); // only lower 6 bits are used
723 LLAssert(llong(0x80000000, 0).ushr(-1) == llong(0, 1)); // only lower 6 bits are used
725 // operator&(llong)
726 LLAssert((llong(0x55555555, 0x55555555) & llong(0xaaaaffff, 0xffffaaaa)) == llong(0x00005555, 0x55550000));
728 // operator|(llong)
729 LLAssert((llong(0x55555555, 0x55555555) | llong(0xaaaaffff, 0xffffaaaa)) == llong(0xffffffff, 0xffffffff));
731 // operator^(llong)
732 LLAssert((llong(0x55555555, 0x55555555) ^ llong(0xaaaaffff, 0xffffaaaa)) == llong(0xffffaaaa, 0xaaaaffff));
735 LLAssert((llong(0x55555555, 0x55555555) & (uint32_t)0xffffaaaa) == llong(0, 0x55550000));
738 LLAssert((llong(0x55555555, 0x55555555) | (uint32_t)0xffffaaaa) == llong(0x55555555, 0xffffffff));
741 LLAssert((llong(0x55555555, 0x55555555) ^ (uint32_t)0xffffaaaa) == llong(0x55555555, 0xaaaaffff));
744 LLAssert(~llong(0x55555555, 0x55555555) == llong(0xaaaaaaaa, 0xaaaaaaaa));
746 // operator&=(llong)
747 LLAssert((llong(0x55555555, 0x55555555) &= llong(0xaaaaffff, 0xffffaaaa)) == llong(0x00005555, 0x55550000));
749 // operator|=(llong)
750 LLAssert((llong(0x55555555, 0x55555555) |= llong(0xaaaaffff, 0xffffaaaa)) == llong(0xffffffff, 0xffffffff));
752 // operator^=(llong)
753 LLAssert((llong(0x55555555, 0x55555555) ^= llong(0xaaaaffff, 0xffffaaaa)) == llong(0xffffaaaa, 0xaaaaffff));
756 LLAssert((llong(0x55555555, 0x55555555) &= (uint32_t)0xffffaaaa) == llong(0, 0x55550000));
759 LLAssert((llong(0x55555555, 0x55555555) |= (uint32_t)0xffffaaaa) == llong(0x55555555, 0xffffffff));
762 LLAssert((llong(0x55555555, 0x55555555) ^= (uint32_t)0xffffaaaa) == llong(0x55555555, 0xaaaaffff));
765 LLAssert(llong(1, 0) == ++llong(0,0xffffffff));
768 LLAssert(llong(0,0xffffffff) == --llong(1, 0));
772 llong n(0, 0xffffffff);
773 LLAssert(llong(0, 0xffffffff) == n++);
774 LLAssert(llong(1, 0) == n);
779 llong n(1, 0);
780 LLAssert(llong(1, 0) == n--);
781 LLAssert(llong(0, 0xffffffff) == n);
785 LLAssert(llong(0, 0) == -llong(0, 0));
786 LLAssert(llong(0xffffffff, 0xffffffff) == -llong(0, 1));
787 LLAssert(llong(0, 1) == -llong(0xffffffff, 0xffffffff));
788 LLAssert(llong(0x7fffffff, 0xffffffff) == -llong(0x80000000, 1));
789 LLAssert(llong(0x80000000, 0) == -llong(0x80000000, 0)); // !!! we don't handle overflow
793 llong n;
794 LLAssert((n -= llong(0, 1)) == llong(0xffffffff, 0xffffffff));
795 LLAssert(n == llong(0xffffffff, 0xffffffff));
797 n = llong(1, 0);
798 LLAssert((n -= llong(0, 1)) == llong(0, 0xffffffff));
799 LLAssert(n == llong(0, 0xffffffff));
804 llong n;
805 LLAssert((n - llong(0, 1)) == llong(0xffffffff, 0xffffffff));
806 LLAssert(n == llong(0, 0));
808 n = llong(1, 0);
809 LLAssert((n - llong(0, 1)) == llong(0, 0xffffffff));
810 LLAssert(n == llong(1, 0));
815 llong n(0xffffffff, 0xffffffff);
816 LLAssert((n += llong(0, 1)) == llong(0, 0));
817 LLAssert(n == llong(0, 0));
819 n = llong(0, 0xffffffff);
820 LLAssert((n += llong(0, 1)) == llong(1, 0));
821 LLAssert(n == llong(1, 0));
826 llong n(0xffffffff, 0xffffffff);
827 LLAssert((n + llong(0, 1)) == llong(0, 0));
828 LLAssert(n == llong(0xffffffff, 0xffffffff));
830 n = llong(0, 0xffffffff);
831 LLAssert((n + llong(0, 1)) == llong(1, 0));
832 LLAssert(n == llong(0, 0xffffffff));
851 const llong ZERO;
852 const llong ONE(0, 1);
853 const llong NEG_ONE((int32_t)-1);
854 const llong THREE(0, 3);
855 const llong NEG_THREE((int32_t)-3);
856 const llong TWO_TO_16(0, 0x10000);
857 const llong NEG_TWO_TO_16 = -TWO_TO_16;
858 const llong TWO_TO_32(1, 0);
859 const llong NEG_TWO_TO_32 = -TWO_TO_32;
861 const llong NINE(0, 9);
862 const llong NEG_NINE = -NINE;
864 const llong TWO_TO_16X3(0, 0x00030000);
865 const llong NEG_TWO_TO_16X3 = -TWO_TO_16X3;
867 const llong TWO_TO_32X3(3, 0);
868 const llong NEG_TWO_TO_32X3 = -TWO_TO_32X3;
870 const llong TWO_TO_48(0x10000, 0);
871 const llong NEG_TWO_TO_48 = -TWO_TO_48;
874 const llong* values[VALUE_WIDTH] = {
878 const llong* answers[VALUE_WIDTH*VALUE_WIDTH] = {
892 llong lhs = *values[i];
893 llong rhs = *values[j];
894 llong ans = *answers[i*VALUE_WIDTH + j];
896 llong n = lhs;
912 const llong ZERO;
913 const llong ONE(0, 1);
914 const llong NEG_ONE = -ONE;
915 const llong MAX(0x7fffffff, 0xffffffff);
916 const llong MIN(0x80000000, 0);
917 const llong TWO(0, 2);
918 const llong NEG_TWO = -TWO;
919 const llong FIVE(0, 5);
920 const llong NEG_FIVE = -FIVE;
921 const llong TWO_TO_32(1, 0);
922 const llong NEG_TWO_TO_32 = -TWO_TO_32;
923 const llong TWO_TO_32d5 = llong(TWO_TO_32.asDouble()/5.0);
924 const llong NEG_TWO_TO_32d5 = -TWO_TO_32d5;
925 const llong TWO_TO_32X5 = TWO_TO_32 * FIVE;
926 const llong NEG_TWO_TO_32X5 = -TWO_TO_32X5;
928 const llong* tuples[] = { // lhs, rhs, ans
964 const llong lhs = *tuples[i*TUPLE_WIDTH+0];
965 const llong rhs = *tuples[i*TUPLE_WIDTH+1];
966 const llong ans = *tuples[i*TUPLE_WIDTH+2];
968 llong n = lhs;
983 const llong ZERO;
984 const llong ONE(0, 1);
985 const llong TWO(0, 2);
986 const llong THREE(0,3);
987 const llong FOUR(0, 4);
988 const llong FIVE(0, 5);
989 const llong SIX(0, 6);
991 const llong NEG_ONE = -ONE;
992 const llong NEG_TWO = -TWO;
993 const llong NEG_THREE = -THREE;
994 const llong NEG_FOUR = -FOUR;
995 const llong NEG_FIVE = -FIVE;
996 const llong NEG_SIX = -SIX;
998 const llong NINETY_NINE(0, 99);
999 const llong HUNDRED(0, 100);
1000 const llong HUNDRED_ONE(0, 101);
1002 const llong BIG(0x12345678, 0x9abcdef0);
1003 const llong BIG_FIVE(BIG * FIVE);
1004 const llong BIG_FIVEm1 = BIG_FIVE - ONE;
1005 const llong BIG_FIVEp1 = BIG_FIVE + ONE;
1007 const llong* tuples[] = {
1044 const llong lhs = *tuples[i*TUPLE_WIDTH+0];
1045 const llong rhs = *tuples[i*TUPLE_WIDTH+1];
1046 const llong ans = *tuples[i*TUPLE_WIDTH+2];
1048 llong n = lhs;
1062 LLAssert(llong(0, 0).pow(0) == llong(0, 0));
1063 LLAssert(llong(0, 0).pow(2) == llong(0, 0));
1064 LLAssert(llong(0, 2).pow(0) == llong(0, 1));
1065 LLAssert(llong(0, 2).pow(2) == llong(0, 4));
1066 LLAssert(llong(0, 2).pow(32) == llong(1, 0));
1067 LLAssert(llong(0, 5).pow(10) == llong((double)5.0 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5));
1071 const llong n(0xffffffff,0xffffffff);
1072 LLAssert(n.abs() == llong(0, 1));
1084 LLAssert(llong::atoll(empty) == llong(0, 0));
1085 LLAssert(llong::atoll(zero) == llong(0, 0));
1086 LLAssert(llong::atoll(neg_one) == llong(0xffffffff, 0xffffffff));
1087 LLAssert(llong::atoll(neg_12345) == -llong(0, 12345));
1088 LLAssert(llong::atoll(big1, 16) == llong(0x12345678, 0x9abcdef0));
1089 LLAssert(llong::atoll(big2, 16) == llong(0xffffffff, 0xffffffff));
1099 LLAssert(llong::utoll(uempty) == llong(0, 0));
1100 LLAssert(llong::utoll(uzero) == llong(0, 0));
1101 LLAssert(llong::utoll(uneg_one) == llong(0xffffffff, 0xffffffff));
1102 LLAssert(llong::utoll(uneg_12345) == -llong(0, 12345));
1103 LLAssert(llong::utoll(ubig1, 16) == llong(0x12345678, 0x9abcdef0));
1104 LLAssert(llong::utoll(ubig2, 16) == llong(0xffffffff, 0xffffffff));
1111 LLAssert((llong(0, 0).lltoa(buf, (uint32_t)sizeof(buf)) == 1) && (strcmp(buf, zero) == 0));
1112 LLAssert((llong(0xffffffff, 0xffffffff).lltoa(buf, (uint32_t)sizeof(buf)) == 2) && (strcmp(buf, neg_one) == 0));
1113 LLAssert(((-llong(0, 12345)).lltoa(buf, (uint32_t)sizeof(buf)) == 6) && (strcmp(buf, neg_12345) == 0));
1114 LLAssert((llong(0x12345678, 0x9abcdef0).lltoa(buf, (uint32_t)sizeof(buf), 16) == 16) && (strcmp(buf, big1) == 0));
1122 LLAssert((llong(0, 0).lltou(buf, (uint32_t)sizeof(buf)) == 1) && (u_strcmp(buf, uzero) == 0));
1123 LLAssert((llong(0xffffffff, 0xffffffff).lltou(buf, (uint32_t)sizeof(buf)) == 2) && (u_strcmp(buf, uneg_one) == 0));
1124 LLAssert(((-llong(0, 12345)).lltou(buf, (uint32_t)sizeof(buf)) == 6) && (u_strcmp(buf, uneg_12345) == 0));
1125 LLAssert((llong(0x12345678, 0x9abcdef0).lltou(buf, (uint32_t)sizeof(buf), 16) == 16) && (u_strcmp(buf, ubig1) == 0));