Index: include/llvm/ADT/APFloat.h =================================================================== --- include/llvm/ADT/APFloat.h +++ include/llvm/ADT/APFloat.h @@ -135,16 +135,16 @@ /// \name Floating Point Semantics. /// @{ - static const fltSemantics IEEEhalf; - static const fltSemantics IEEEsingle; - static const fltSemantics IEEEdouble; - static const fltSemantics IEEEquad; - static const fltSemantics PPCDoubleDouble; - static const fltSemantics x87DoubleExtended; + static const fltSemantics &IEEEhalf(); + static const fltSemantics &IEEEsingle(); + static const fltSemantics &IEEEdouble(); + static const fltSemantics &IEEEquad(); + static const fltSemantics &PPCDoubleDouble(); + static const fltSemantics &x87DoubleExtended(); /// A Pseudo fltsemantic used to construct APFloats that cannot conflict with /// anything real. - static const fltSemantics Bogus; + static const fltSemantics &Bogus(); /// @} @@ -643,7 +643,7 @@ explicit Storage(IEEEFloat F, const fltSemantics &S); explicit Storage(DoubleAPFloat F, const fltSemantics &S) : Double(std::move(F)) { - assert(&S == &PPCDoubleDouble); + assert(&S == &PPCDoubleDouble()); } template @@ -720,9 +720,9 @@ static_assert(std::is_same::value || std::is_same::value, ""); if (std::is_same::value) { - return &Semantics == &PPCDoubleDouble; + return &Semantics == &PPCDoubleDouble(); } - return &Semantics != &PPCDoubleDouble; + return &Semantics != &PPCDoubleDouble(); } IEEEFloat &getIEEE() { @@ -764,7 +764,7 @@ // FIXME: This is due to clang 3.3 (or older version) always checks for the // default constructor in an array aggregate initialization, even if no // elements in the array is default initialized. - APFloat() : U(IEEEdouble) { + APFloat() : U(IEEEdouble()) { llvm_unreachable("This is a workaround for old clang."); } @@ -780,8 +780,8 @@ APFloat(const fltSemantics &Semantics, uninitializedTag) : U(Semantics, uninitialized) {} APFloat(const fltSemantics &Semantics, const APInt &I) : U(Semantics, I) {} - explicit APFloat(double d) : U(IEEEFloat(d), IEEEdouble) {} - explicit APFloat(float f) : U(IEEEFloat(f), IEEEsingle) {} + explicit APFloat(double d) : U(IEEEFloat(d), IEEEdouble()) {} + explicit APFloat(float f) : U(IEEEFloat(f), IEEEsingle()) {} APFloat(const APFloat &RHS) = default; APFloat(APFloat &&RHS) = default; Index: include/llvm/CodeGen/SelectionDAG.h =================================================================== --- include/llvm/CodeGen/SelectionDAG.h +++ include/llvm/CodeGen/SelectionDAG.h @@ -1180,12 +1180,12 @@ static const fltSemantics &EVTToAPFloatSemantics(EVT VT) { switch (VT.getScalarType().getSimpleVT().SimpleTy) { default: llvm_unreachable("Unknown FP format"); - case MVT::f16: return APFloat::IEEEhalf; - case MVT::f32: return APFloat::IEEEsingle; - case MVT::f64: return APFloat::IEEEdouble; - case MVT::f80: return APFloat::x87DoubleExtended; - case MVT::f128: return APFloat::IEEEquad; - case MVT::ppcf128: return APFloat::PPCDoubleDouble; + case MVT::f16: return APFloat::IEEEhalf(); + case MVT::f32: return APFloat::IEEEsingle(); + case MVT::f64: return APFloat::IEEEdouble(); + case MVT::f80: return APFloat::x87DoubleExtended(); + case MVT::f128: return APFloat::IEEEquad(); + case MVT::ppcf128: return APFloat::PPCDoubleDouble(); } } Index: include/llvm/IR/Type.h =================================================================== --- include/llvm/IR/Type.h +++ include/llvm/IR/Type.h @@ -166,12 +166,12 @@ const fltSemantics &getFltSemantics() const { switch (getTypeID()) { - case HalfTyID: return APFloat::IEEEhalf; - case FloatTyID: return APFloat::IEEEsingle; - case DoubleTyID: return APFloat::IEEEdouble; - case X86_FP80TyID: return APFloat::x87DoubleExtended; - case FP128TyID: return APFloat::IEEEquad; - case PPC_FP128TyID: return APFloat::PPCDoubleDouble; + case HalfTyID: return APFloat::IEEEhalf(); + case FloatTyID: return APFloat::IEEEsingle(); + case DoubleTyID: return APFloat::IEEEdouble(); + case X86_FP80TyID: return APFloat::x87DoubleExtended(); + case FP128TyID: return APFloat::IEEEquad(); + case PPC_FP128TyID: return APFloat::PPCDoubleDouble(); default: llvm_unreachable("Invalid floating type"); } } Index: lib/Analysis/ConstantFolding.cpp =================================================================== --- lib/Analysis/ConstantFolding.cpp +++ lib/Analysis/ConstantFolding.cpp @@ -1426,7 +1426,7 @@ if (Ty->isHalfTy()) { APFloat APF(V); bool unused; - APF.convert(APFloat::IEEEhalf, APFloat::rmNearestTiesToEven, &unused); + APF.convert(APFloat::IEEEhalf(), APFloat::rmNearestTiesToEven, &unused); return ConstantFP::get(Ty->getContext(), APF); } if (Ty->isFloatTy()) @@ -1517,7 +1517,7 @@ bool unused; APFloat APF = Op->getValueAPF(); - APF.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven, &unused); + APF.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven, &unused); return APF.convertToDouble(); } @@ -1535,7 +1535,7 @@ APFloat Val(Op->getValueAPF()); bool lost = false; - Val.convert(APFloat::IEEEhalf, APFloat::rmNearestTiesToEven, &lost); + Val.convert(APFloat::IEEEhalf(), APFloat::rmNearestTiesToEven, &lost); return ConstantInt::get(Ty->getContext(), Val.bitcastToAPInt()); } @@ -1710,7 +1710,7 @@ case Intrinsic::bitreverse: return ConstantInt::get(Ty->getContext(), Op->getValue().reverseBits()); case Intrinsic::convert_from_fp16: { - APFloat Val(APFloat::IEEEhalf, Op->getValue()); + APFloat Val(APFloat::IEEEhalf(), Op->getValue()); bool lost = false; APFloat::opStatus status = Val.convert( Index: lib/AsmParser/LLLexer.cpp =================================================================== --- lib/AsmParser/LLLexer.cpp +++ lib/AsmParser/LLLexer.cpp @@ -874,7 +874,7 @@ // HexFPConstant - Floating point constant represented in IEEE format as a // hexadecimal number for when exponential notation is not precise enough. // Half, Float, and double only. - APFloatVal = APFloat(APFloat::IEEEdouble, + APFloatVal = APFloat(APFloat::IEEEdouble(), APInt(64, HexIntToVal(TokStart + 2, CurPtr))); return lltok::APFloat; } @@ -885,20 +885,20 @@ case 'K': // F80HexFPConstant - x87 long double in hexadecimal format (10 bytes) FP80HexToIntPair(TokStart+3, CurPtr, Pair); - APFloatVal = APFloat(APFloat::x87DoubleExtended, APInt(80, Pair)); + APFloatVal = APFloat(APFloat::x87DoubleExtended(), APInt(80, Pair)); return lltok::APFloat; case 'L': // F128HexFPConstant - IEEE 128-bit in hexadecimal format (16 bytes) HexToIntPair(TokStart+3, CurPtr, Pair); - APFloatVal = APFloat(APFloat::IEEEquad, APInt(128, Pair)); + APFloatVal = APFloat(APFloat::IEEEquad(), APInt(128, Pair)); return lltok::APFloat; case 'M': // PPC128HexFPConstant - PowerPC 128-bit in hexadecimal format (16 bytes) HexToIntPair(TokStart+3, CurPtr, Pair); - APFloatVal = APFloat(APFloat::PPCDoubleDouble, APInt(128, Pair)); + APFloatVal = APFloat(APFloat::PPCDoubleDouble(), APInt(128, Pair)); return lltok::APFloat; case 'H': - APFloatVal = APFloat(APFloat::IEEEhalf, + APFloatVal = APFloat(APFloat::IEEEhalf(), APInt(16,HexIntToVal(TokStart+3, CurPtr))); return lltok::APFloat; } @@ -965,7 +965,7 @@ } } - APFloatVal = APFloat(APFloat::IEEEdouble, + APFloatVal = APFloat(APFloat::IEEEdouble(), StringRef(TokStart, CurPtr - TokStart)); return lltok::APFloat; } @@ -1002,7 +1002,7 @@ } } - APFloatVal = APFloat(APFloat::IEEEdouble, + APFloatVal = APFloat(APFloat::IEEEdouble(), StringRef(TokStart, CurPtr - TokStart)); return lltok::APFloat; } Index: lib/AsmParser/LLParser.cpp =================================================================== --- lib/AsmParser/LLParser.cpp +++ lib/AsmParser/LLParser.cpp @@ -4460,13 +4460,13 @@ // The lexer has no type info, so builds all half, float, and double FP // constants as double. Fix this here. Long double does not need this. - if (&ID.APFloatVal.getSemantics() == &APFloat::IEEEdouble) { + if (&ID.APFloatVal.getSemantics() == &APFloat::IEEEdouble()) { bool Ignored; if (Ty->isHalfTy()) - ID.APFloatVal.convert(APFloat::IEEEhalf, APFloat::rmNearestTiesToEven, + ID.APFloatVal.convert(APFloat::IEEEhalf(), APFloat::rmNearestTiesToEven, &Ignored); else if (Ty->isFloatTy()) - ID.APFloatVal.convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven, + ID.APFloatVal.convert(APFloat::IEEEsingle(), APFloat::rmNearestTiesToEven, &Ignored); } V = ConstantFP::get(Context, ID.APFloatVal); Index: lib/Bitcode/Reader/BitcodeReader.cpp =================================================================== --- lib/Bitcode/Reader/BitcodeReader.cpp +++ lib/Bitcode/Reader/BitcodeReader.cpp @@ -3291,26 +3291,26 @@ if (Record.empty()) return error("Invalid record"); if (CurTy->isHalfTy()) - V = ConstantFP::get(Context, APFloat(APFloat::IEEEhalf, + V = ConstantFP::get(Context, APFloat(APFloat::IEEEhalf(), APInt(16, (uint16_t)Record[0]))); else if (CurTy->isFloatTy()) - V = ConstantFP::get(Context, APFloat(APFloat::IEEEsingle, + V = ConstantFP::get(Context, APFloat(APFloat::IEEEsingle(), APInt(32, (uint32_t)Record[0]))); else if (CurTy->isDoubleTy()) - V = ConstantFP::get(Context, APFloat(APFloat::IEEEdouble, + V = ConstantFP::get(Context, APFloat(APFloat::IEEEdouble(), APInt(64, Record[0]))); else if (CurTy->isX86_FP80Ty()) { // Bits are not stored the same way as a normal i80 APInt, compensate. uint64_t Rearrange[2]; Rearrange[0] = (Record[1] & 0xffffLL) | (Record[0] << 16); Rearrange[1] = Record[0] >> 48; - V = ConstantFP::get(Context, APFloat(APFloat::x87DoubleExtended, + V = ConstantFP::get(Context, APFloat(APFloat::x87DoubleExtended(), APInt(80, Rearrange))); } else if (CurTy->isFP128Ty()) - V = ConstantFP::get(Context, APFloat(APFloat::IEEEquad, + V = ConstantFP::get(Context, APFloat(APFloat::IEEEquad(), APInt(128, Record))); else if (CurTy->isPPC_FP128Ty()) - V = ConstantFP::get(Context, APFloat(APFloat::PPCDoubleDouble, + V = ConstantFP::get(Context, APFloat(APFloat::PPCDoubleDouble(), APInt(128, Record))); else V = UndefValue::get(CurTy); Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp =================================================================== --- lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -746,7 +746,7 @@ // There is no good way to print long double. Convert a copy to // double. Ah well, it's only a comment. bool ignored; - APF.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven, + APF.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven, &ignored); OS << "(long double) " << APF.convertToDouble(); } Index: lib/CodeGen/MachineInstr.cpp =================================================================== --- lib/CodeGen/MachineInstr.cpp +++ lib/CodeGen/MachineInstr.cpp @@ -401,7 +401,7 @@ } else if (getFPImm()->getType()->isHalfTy()) { APFloat APF = getFPImm()->getValueAPF(); bool Unused; - APF.convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven, &Unused); + APF.convert(APFloat::IEEEsingle(), APFloat::rmNearestTiesToEven, &Unused); OS << "half " << APF.convertToFloat(); } else { OS << getFPImm()->getValueAPF().convertToDouble(); Index: lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp =================================================================== --- lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp +++ lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp @@ -1466,7 +1466,7 @@ // TODO: Are there fast-math-flags to propagate to this FADD? Lo = DAG.getNode(ISD::FADD, dl, VT, Hi, - DAG.getConstantFP(APFloat(APFloat::PPCDoubleDouble, + DAG.getConstantFP(APFloat(APFloat::PPCDoubleDouble(), APInt(128, Parts)), dl, MVT::ppcf128)); Lo = DAG.getSelectCC(dl, Src, DAG.getConstant(0, dl, SrcVT), @@ -1631,7 +1631,7 @@ assert(N->getOperand(0).getValueType() == MVT::ppcf128 && "Logic only correct for ppcf128!"); const uint64_t TwoE31[] = {0x41e0000000000000LL, 0}; - APFloat APF = APFloat(APFloat::PPCDoubleDouble, APInt(128, TwoE31)); + APFloat APF = APFloat(APFloat::PPCDoubleDouble(), APInt(128, TwoE31)); SDValue Tmp = DAG.getConstantFP(APF, dl, MVT::ppcf128); // X>=2^31 ? (int)(X-2^31)+0x80000000 : (int)X // FIXME: generated code sucks. Index: lib/CodeGen/SelectionDAG/SelectionDAG.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -3060,13 +3060,13 @@ } case ISD::BITCAST: if (VT == MVT::f16 && C->getValueType(0) == MVT::i16) - return getConstantFP(APFloat(APFloat::IEEEhalf, Val), DL, VT); + return getConstantFP(APFloat(APFloat::IEEEhalf(), Val), DL, VT); if (VT == MVT::f32 && C->getValueType(0) == MVT::i32) - return getConstantFP(APFloat(APFloat::IEEEsingle, Val), DL, VT); + return getConstantFP(APFloat(APFloat::IEEEsingle(), Val), DL, VT); if (VT == MVT::f64 && C->getValueType(0) == MVT::i64) - return getConstantFP(APFloat(APFloat::IEEEdouble, Val), DL, VT); + return getConstantFP(APFloat(APFloat::IEEEdouble(), Val), DL, VT); if (VT == MVT::f128 && C->getValueType(0) == MVT::i128) - return getConstantFP(APFloat(APFloat::IEEEquad, Val), DL, VT); + return getConstantFP(APFloat(APFloat::IEEEquad(), Val), DL, VT); break; case ISD::BSWAP: return getConstant(Val.byteSwap(), DL, VT, C->isTargetOpcode(), Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -4170,7 +4170,7 @@ /// getF32Constant - Get 32-bit floating point constant. static SDValue getF32Constant(SelectionDAG &DAG, unsigned Flt, const SDLoc &dl) { - return DAG.getConstantFP(APFloat(APFloat::IEEEsingle, APInt(32, Flt)), dl, + return DAG.getConstantFP(APFloat(APFloat::IEEEsingle(), APInt(32, Flt)), dl, MVT::f32); } Index: lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp @@ -425,9 +425,9 @@ } else if (const ConstantSDNode *CSDN = dyn_cast(this)) { OS << '<' << CSDN->getAPIntValue() << '>'; } else if (const ConstantFPSDNode *CSDN = dyn_cast(this)) { - if (&CSDN->getValueAPF().getSemantics()==&APFloat::IEEEsingle) + if (&CSDN->getValueAPF().getSemantics()==&APFloat::IEEEsingle()) OS << '<' << CSDN->getValueAPF().convertToFloat() << '>'; - else if (&CSDN->getValueAPF().getSemantics()==&APFloat::IEEEdouble) + else if (&CSDN->getValueAPF().getSemantics()==&APFloat::IEEEdouble()) OS << '<' << CSDN->getValueAPF().convertToDouble() << '>'; else { OS << "getType()->isDoubleTy()) GV.DoubleVal = GV.IntVal.roundToDouble(); else if (CE->getType()->isX86_FP80Ty()) { - APFloat apf = APFloat::getZero(APFloat::x87DoubleExtended); + APFloat apf = APFloat::getZero(APFloat::x87DoubleExtended()); (void)apf.convertFromAPInt(GV.IntVal, false, APFloat::rmNearestTiesToEven); @@ -707,7 +707,7 @@ else if (CE->getType()->isDoubleTy()) GV.DoubleVal = GV.IntVal.signedRoundToDouble(); else if (CE->getType()->isX86_FP80Ty()) { - APFloat apf = APFloat::getZero(APFloat::x87DoubleExtended); + APFloat apf = APFloat::getZero(APFloat::x87DoubleExtended()); (void)apf.convertFromAPInt(GV.IntVal, true, APFloat::rmNearestTiesToEven); @@ -724,7 +724,7 @@ else if (Op0->getType()->isDoubleTy()) GV.IntVal = APIntOps::RoundDoubleToAPInt(GV.DoubleVal, BitWidth); else if (Op0->getType()->isX86_FP80Ty()) { - APFloat apf = APFloat(APFloat::x87DoubleExtended, GV.IntVal); + APFloat apf = APFloat(APFloat::x87DoubleExtended(), GV.IntVal); uint64_t v; bool ignored; (void)apf.convertToInteger(&v, BitWidth, Index: lib/IR/AsmWriter.cpp =================================================================== --- lib/IR/AsmWriter.cpp +++ lib/IR/AsmWriter.cpp @@ -1106,15 +1106,15 @@ } if (const ConstantFP *CFP = dyn_cast(CV)) { - if (&CFP->getValueAPF().getSemantics() == &APFloat::IEEEsingle || - &CFP->getValueAPF().getSemantics() == &APFloat::IEEEdouble) { + if (&CFP->getValueAPF().getSemantics() == &APFloat::IEEEsingle() || + &CFP->getValueAPF().getSemantics() == &APFloat::IEEEdouble()) { // We would like to output the FP constant value in exponential notation, // but we cannot do this if doing so will lose precision. Check here to // make sure that we only output it in exponential format if we can parse // the value back and get the same value. // bool ignored; - bool isDouble = &CFP->getValueAPF().getSemantics()==&APFloat::IEEEdouble; + bool isDouble = &CFP->getValueAPF().getSemantics()==&APFloat::IEEEdouble(); bool isInf = CFP->getValueAPF().isInfinity(); bool isNaN = CFP->getValueAPF().isNaN(); if (!isInf && !isNaN) { @@ -1131,7 +1131,7 @@ ((StrVal[0] == '-' || StrVal[0] == '+') && (StrVal[1] >= '0' && StrVal[1] <= '9'))) { // Reparse stringized version! - if (APFloat(APFloat::IEEEdouble, StrVal).convertToDouble() == Val) { + if (APFloat(APFloat::IEEEdouble(), StrVal).convertToDouble() == Val) { Out << StrVal; return; } @@ -1146,7 +1146,7 @@ APFloat apf = CFP->getValueAPF(); // Floats are represented in ASCII IR as double, convert. if (!isDouble) - apf.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven, + apf.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven, &ignored); Out << format_hex(apf.bitcastToAPInt().getZExtValue(), 0, /*Upper=*/true); return; @@ -1157,26 +1157,26 @@ // fixed number of hex digits. Out << "0x"; APInt API = CFP->getValueAPF().bitcastToAPInt(); - if (&CFP->getValueAPF().getSemantics() == &APFloat::x87DoubleExtended) { + if (&CFP->getValueAPF().getSemantics() == &APFloat::x87DoubleExtended()) { Out << 'K'; Out << format_hex_no_prefix(API.getHiBits(16).getZExtValue(), 4, /*Upper=*/true); Out << format_hex_no_prefix(API.getLoBits(64).getZExtValue(), 16, /*Upper=*/true); return; - } else if (&CFP->getValueAPF().getSemantics() == &APFloat::IEEEquad) { + } else if (&CFP->getValueAPF().getSemantics() == &APFloat::IEEEquad()) { Out << 'L'; Out << format_hex_no_prefix(API.getLoBits(64).getZExtValue(), 16, /*Upper=*/true); Out << format_hex_no_prefix(API.getHiBits(64).getZExtValue(), 16, /*Upper=*/true); - } else if (&CFP->getValueAPF().getSemantics() == &APFloat::PPCDoubleDouble) { + } else if (&CFP->getValueAPF().getSemantics() == &APFloat::PPCDoubleDouble()) { Out << 'M'; Out << format_hex_no_prefix(API.getLoBits(64).getZExtValue(), 16, /*Upper=*/true); Out << format_hex_no_prefix(API.getHiBits(64).getZExtValue(), 16, /*Upper=*/true); - } else if (&CFP->getValueAPF().getSemantics() == &APFloat::IEEEhalf) { + } else if (&CFP->getValueAPF().getSemantics() == &APFloat::IEEEhalf()) { Out << 'H'; Out << format_hex_no_prefix(API.getZExtValue(), 4, /*Upper=*/true); Index: lib/IR/ConstantFold.cpp =================================================================== --- lib/IR/ConstantFold.cpp +++ lib/IR/ConstantFold.cpp @@ -591,13 +591,13 @@ if (ConstantFP *FPC = dyn_cast(V)) { bool ignored; APFloat Val = FPC->getValueAPF(); - Val.convert(DestTy->isHalfTy() ? APFloat::IEEEhalf : - DestTy->isFloatTy() ? APFloat::IEEEsingle : - DestTy->isDoubleTy() ? APFloat::IEEEdouble : - DestTy->isX86_FP80Ty() ? APFloat::x87DoubleExtended : - DestTy->isFP128Ty() ? APFloat::IEEEquad : - DestTy->isPPC_FP128Ty() ? APFloat::PPCDoubleDouble : - APFloat::Bogus, + Val.convert(DestTy->isHalfTy() ? APFloat::IEEEhalf() : + DestTy->isFloatTy() ? APFloat::IEEEsingle() : + DestTy->isDoubleTy() ? APFloat::IEEEdouble() : + DestTy->isX86_FP80Ty() ? APFloat::x87DoubleExtended() : + DestTy->isFP128Ty() ? APFloat::IEEEquad() : + DestTy->isPPC_FP128Ty() ? APFloat::PPCDoubleDouble() : + APFloat::Bogus(), APFloat::rmNearestTiesToEven, &ignored); return ConstantFP::get(V->getContext(), Val); } Index: lib/IR/Constants.cpp =================================================================== --- lib/IR/Constants.cpp +++ lib/IR/Constants.cpp @@ -198,22 +198,22 @@ return ConstantInt::get(Ty, 0); case Type::HalfTyID: return ConstantFP::get(Ty->getContext(), - APFloat::getZero(APFloat::IEEEhalf)); + APFloat::getZero(APFloat::IEEEhalf())); case Type::FloatTyID: return ConstantFP::get(Ty->getContext(), - APFloat::getZero(APFloat::IEEEsingle)); + APFloat::getZero(APFloat::IEEEsingle())); case Type::DoubleTyID: return ConstantFP::get(Ty->getContext(), - APFloat::getZero(APFloat::IEEEdouble)); + APFloat::getZero(APFloat::IEEEdouble())); case Type::X86_FP80TyID: return ConstantFP::get(Ty->getContext(), - APFloat::getZero(APFloat::x87DoubleExtended)); + APFloat::getZero(APFloat::x87DoubleExtended())); case Type::FP128TyID: return ConstantFP::get(Ty->getContext(), - APFloat::getZero(APFloat::IEEEquad)); + APFloat::getZero(APFloat::IEEEquad())); case Type::PPC_FP128TyID: return ConstantFP::get(Ty->getContext(), - APFloat(APFloat::PPCDoubleDouble, + APFloat(APFloat::PPCDoubleDouble(), APInt::getNullValue(128))); case Type::PointerTyID: return ConstantPointerNull::get(cast(Ty)); @@ -604,18 +604,18 @@ static const fltSemantics *TypeToFloatSemantics(Type *Ty) { if (Ty->isHalfTy()) - return &APFloat::IEEEhalf; + return &APFloat::IEEEhalf(); if (Ty->isFloatTy()) - return &APFloat::IEEEsingle; + return &APFloat::IEEEsingle(); if (Ty->isDoubleTy()) - return &APFloat::IEEEdouble; + return &APFloat::IEEEdouble(); if (Ty->isX86_FP80Ty()) - return &APFloat::x87DoubleExtended; + return &APFloat::x87DoubleExtended(); else if (Ty->isFP128Ty()) - return &APFloat::IEEEquad; + return &APFloat::IEEEquad(); assert(Ty->isPPC_FP128Ty() && "Unknown FP format"); - return &APFloat::PPCDoubleDouble; + return &APFloat::PPCDoubleDouble(); } void ConstantFP::anchor() { } @@ -689,18 +689,18 @@ if (!Slot) { Type *Ty; - if (&V.getSemantics() == &APFloat::IEEEhalf) + if (&V.getSemantics() == &APFloat::IEEEhalf()) Ty = Type::getHalfTy(Context); - else if (&V.getSemantics() == &APFloat::IEEEsingle) + else if (&V.getSemantics() == &APFloat::IEEEsingle()) Ty = Type::getFloatTy(Context); - else if (&V.getSemantics() == &APFloat::IEEEdouble) + else if (&V.getSemantics() == &APFloat::IEEEdouble()) Ty = Type::getDoubleTy(Context); - else if (&V.getSemantics() == &APFloat::x87DoubleExtended) + else if (&V.getSemantics() == &APFloat::x87DoubleExtended()) Ty = Type::getX86_FP80Ty(Context); - else if (&V.getSemantics() == &APFloat::IEEEquad) + else if (&V.getSemantics() == &APFloat::IEEEquad()) Ty = Type::getFP128Ty(Context); else { - assert(&V.getSemantics() == &APFloat::PPCDoubleDouble && + assert(&V.getSemantics() == &APFloat::PPCDoubleDouble() && "Unknown FP format"); Ty = Type::getPPC_FP128Ty(Context); } @@ -1215,40 +1215,40 @@ // FIXME rounding mode needs to be more flexible case Type::HalfTyID: { - if (&Val2.getSemantics() == &APFloat::IEEEhalf) + if (&Val2.getSemantics() == &APFloat::IEEEhalf()) return true; - Val2.convert(APFloat::IEEEhalf, APFloat::rmNearestTiesToEven, &losesInfo); + Val2.convert(APFloat::IEEEhalf(), APFloat::rmNearestTiesToEven, &losesInfo); return !losesInfo; } case Type::FloatTyID: { - if (&Val2.getSemantics() == &APFloat::IEEEsingle) + if (&Val2.getSemantics() == &APFloat::IEEEsingle()) return true; - Val2.convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven, &losesInfo); + Val2.convert(APFloat::IEEEsingle(), APFloat::rmNearestTiesToEven, &losesInfo); return !losesInfo; } case Type::DoubleTyID: { - if (&Val2.getSemantics() == &APFloat::IEEEhalf || - &Val2.getSemantics() == &APFloat::IEEEsingle || - &Val2.getSemantics() == &APFloat::IEEEdouble) + if (&Val2.getSemantics() == &APFloat::IEEEhalf() || + &Val2.getSemantics() == &APFloat::IEEEsingle() || + &Val2.getSemantics() == &APFloat::IEEEdouble()) return true; - Val2.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven, &losesInfo); + Val2.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven, &losesInfo); return !losesInfo; } case Type::X86_FP80TyID: - return &Val2.getSemantics() == &APFloat::IEEEhalf || - &Val2.getSemantics() == &APFloat::IEEEsingle || - &Val2.getSemantics() == &APFloat::IEEEdouble || - &Val2.getSemantics() == &APFloat::x87DoubleExtended; + return &Val2.getSemantics() == &APFloat::IEEEhalf() || + &Val2.getSemantics() == &APFloat::IEEEsingle() || + &Val2.getSemantics() == &APFloat::IEEEdouble() || + &Val2.getSemantics() == &APFloat::x87DoubleExtended(); case Type::FP128TyID: - return &Val2.getSemantics() == &APFloat::IEEEhalf || - &Val2.getSemantics() == &APFloat::IEEEsingle || - &Val2.getSemantics() == &APFloat::IEEEdouble || - &Val2.getSemantics() == &APFloat::IEEEquad; + return &Val2.getSemantics() == &APFloat::IEEEhalf() || + &Val2.getSemantics() == &APFloat::IEEEsingle() || + &Val2.getSemantics() == &APFloat::IEEEdouble() || + &Val2.getSemantics() == &APFloat::IEEEquad(); case Type::PPC_FP128TyID: - return &Val2.getSemantics() == &APFloat::IEEEhalf || - &Val2.getSemantics() == &APFloat::IEEEsingle || - &Val2.getSemantics() == &APFloat::IEEEdouble || - &Val2.getSemantics() == &APFloat::PPCDoubleDouble; + return &Val2.getSemantics() == &APFloat::IEEEhalf() || + &Val2.getSemantics() == &APFloat::IEEEsingle() || + &Val2.getSemantics() == &APFloat::IEEEdouble() || + &Val2.getSemantics() == &APFloat::PPCDoubleDouble(); } } @@ -2615,15 +2615,15 @@ llvm_unreachable("Accessor can only be used when element is float/double!"); case Type::HalfTyID: { auto EltVal = *reinterpret_cast(EltPtr); - return APFloat(APFloat::IEEEhalf, APInt(16, EltVal)); + return APFloat(APFloat::IEEEhalf(), APInt(16, EltVal)); } case Type::FloatTyID: { auto EltVal = *reinterpret_cast(EltPtr); - return APFloat(APFloat::IEEEsingle, APInt(32, EltVal)); + return APFloat(APFloat::IEEEsingle(), APInt(32, EltVal)); } case Type::DoubleTyID: { auto EltVal = *reinterpret_cast(EltPtr); - return APFloat(APFloat::IEEEdouble, APInt(64, EltVal)); + return APFloat(APFloat::IEEEdouble(), APInt(64, EltVal)); } } } Index: lib/IR/Core.cpp =================================================================== --- lib/IR/Core.cpp +++ lib/IR/Core.cpp @@ -980,7 +980,7 @@ bool APFLosesInfo; APFloat APF = cFP->getValueAPF(); - APF.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven, &APFLosesInfo); + APF.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven, &APFLosesInfo); *LosesInfo = APFLosesInfo; return APF.convertToDouble(); } Index: lib/IR/LLVMContextImpl.h =================================================================== --- lib/IR/LLVMContextImpl.h +++ lib/IR/LLVMContextImpl.h @@ -68,8 +68,8 @@ }; struct DenseMapAPFloatKeyInfo { - static inline APFloat getEmptyKey() { return APFloat(APFloat::Bogus, 1); } - static inline APFloat getTombstoneKey() { return APFloat(APFloat::Bogus, 2); } + static inline APFloat getEmptyKey() { return APFloat(APFloat::Bogus(), 1); } + static inline APFloat getTombstoneKey() { return APFloat(APFloat::Bogus(), 2); } static unsigned getHashValue(const APFloat &Key) { return static_cast(hash_value(Key)); } Index: lib/IR/Verifier.cpp =================================================================== --- lib/IR/Verifier.cpp +++ lib/IR/Verifier.cpp @@ -3771,7 +3771,7 @@ if (ConstantFP *CFP0 = mdconst::dyn_extract_or_null(MD->getOperand(0))) { const APFloat &Accuracy = CFP0->getValueAPF(); - Assert(&Accuracy.getSemantics() == &APFloat::IEEEsingle, + Assert(&Accuracy.getSemantics() == &APFloat::IEEEsingle(), "fpmath accuracy must have float type", &I); Assert(Accuracy.isFiniteNonZero() && !Accuracy.isNegative(), "fpmath accuracy not a positive number!", &I); Index: lib/MC/MCParser/AsmParser.cpp =================================================================== --- lib/MC/MCParser/AsmParser.cpp +++ lib/MC/MCParser/AsmParser.cpp @@ -1039,7 +1039,7 @@ return false; } case AsmToken::Real: { - APFloat RealVal(APFloat::IEEEdouble, getTok().getString()); + APFloat RealVal(APFloat::IEEEdouble(), getTok().getString()); uint64_t IntVal = RealVal.bitcastToAPInt().getZExtValue(); Res = MCConstantExpr::create(IntVal, getContext()); EndLoc = Lexer.getTok().getEndLoc(); @@ -1758,10 +1758,10 @@ case DK_SINGLE: case DK_FLOAT: case DK_DC_S: - return parseDirectiveRealValue(IDVal, APFloat::IEEEsingle); + return parseDirectiveRealValue(IDVal, APFloat::IEEEsingle()); case DK_DOUBLE: case DK_DC_D: - return parseDirectiveRealValue(IDVal, APFloat::IEEEdouble); + return parseDirectiveRealValue(IDVal, APFloat::IEEEdouble()); case DK_ALIGN: { bool IsPow2 = !getContext().getAsmInfo()->getAlignmentIsInBytes(); return parseDirectiveAlign(IsPow2, /*ExprSize=*/1); @@ -1940,11 +1940,11 @@ case DK_DCB_B: return parseDirectiveDCB(IDVal, 1); case DK_DCB_D: - return parseDirectiveRealDCB(IDVal, APFloat::IEEEdouble); + return parseDirectiveRealDCB(IDVal, APFloat::IEEEdouble()); case DK_DCB_L: return parseDirectiveDCB(IDVal, 4); case DK_DCB_S: - return parseDirectiveRealDCB(IDVal, APFloat::IEEEsingle); + return parseDirectiveRealDCB(IDVal, APFloat::IEEEsingle()); case DK_DC_X: case DK_DCB_X: return TokError(Twine(IDVal) + Index: lib/Support/APFloat.cpp =================================================================== --- lib/Support/APFloat.cpp +++ lib/Support/APFloat.cpp @@ -57,12 +57,12 @@ unsigned int sizeInBits; }; - const fltSemantics APFloatBase::IEEEhalf = {15, -14, 11, 16}; - const fltSemantics APFloatBase::IEEEsingle = {127, -126, 24, 32}; - const fltSemantics APFloatBase::IEEEdouble = {1023, -1022, 53, 64}; - const fltSemantics APFloatBase::IEEEquad = {16383, -16382, 113, 128}; - const fltSemantics APFloatBase::x87DoubleExtended = {16383, -16382, 64, 80}; - const fltSemantics APFloatBase::Bogus = {0, 0, 0, 0}; + static const fltSemantics semIEEEhalf = {15, -14, 11, 16}; + static const fltSemantics semIEEEsingle = {127, -126, 24, 32}; + static const fltSemantics semIEEEdouble = {1023, -1022, 53, 64}; + static const fltSemantics semIEEEquad = {16383, -16382, 113, 128}; + static const fltSemantics semX87DoubleExtended = {16383, -16382, 64, 80}; + static const fltSemantics semBogus = {0, 0, 0, 0}; /* The PowerPC format consists of two doubles. It does not map cleanly onto the usual format above. It is approximated using twice the @@ -75,7 +75,7 @@ to represent all possible values held by a PPC double-double number, for example: (long double) 1.0 + (long double) 0x1p-106 Should this be replaced by a full emulation of PPC double-double? */ - const fltSemantics APFloatBase::PPCDoubleDouble = {0, 0, 0, 0}; + static const fltSemantics semPPCDoubleDouble = {0, 0, 0, 0}; /* There are temporary semantics for the real PPCDoubleDouble implementation. Currently, APFloat of PPCDoubleDouble holds one PPCDoubleDoubleImpl as the @@ -85,8 +85,30 @@ TODO: Once all functions support DoubleAPFloat mode, we'll change all PPCDoubleDoubleImpl to IEEEdouble and remove PPCDoubleDoubleImpl. */ - static const fltSemantics PPCDoubleDoubleImpl = {1023, -1022 + 53, 53 + 53, - 128}; + static const fltSemantics semPPCDoubleDoubleImpl = {1023, -1022 + 53, 53 + 53, + 128}; + + const fltSemantics &APFloatBase::IEEEhalf() { + return semIEEEhalf; + } + const fltSemantics &APFloatBase::IEEEsingle() { + return semIEEEsingle; + } + const fltSemantics &APFloatBase::IEEEdouble() { + return semIEEEdouble; + } + const fltSemantics &APFloatBase::IEEEquad() { + return semIEEEquad; + } + const fltSemantics &APFloatBase::x87DoubleExtended() { + return semX87DoubleExtended; + } + const fltSemantics &APFloatBase::Bogus() { + return semBogus; + } + const fltSemantics &APFloatBase::PPCDoubleDouble() { + return semPPCDoubleDouble; + } /* A tight upper bound on number of parts required to hold the value pow(5, power) is @@ -683,7 +705,7 @@ // For x87 extended precision, we want to make a NaN, not a // pseudo-NaN. Maybe we should expose the ability to make // pseudo-NaNs? - if (semantics == &APFloat::x87DoubleExtended) + if (semantics == &semX87DoubleExtended) APInt::tcSetBit(significand, QNaNBit + 1); } @@ -708,7 +730,7 @@ category = rhs.category; sign = rhs.sign; - rhs.semantics = &Bogus; + rhs.semantics = &semBogus; return *this; } @@ -828,7 +850,7 @@ assign(rhs); } -IEEEFloat::IEEEFloat(IEEEFloat &&rhs) : semantics(&Bogus) { +IEEEFloat::IEEEFloat(IEEEFloat &&rhs) : semantics(&semBogus) { *this = std::move(rhs); } @@ -1927,8 +1949,8 @@ shift = toSemantics.precision - fromSemantics.precision; bool X86SpecialNan = false; - if (&fromSemantics == &IEEEFloat::x87DoubleExtended && - &toSemantics != &IEEEFloat::x87DoubleExtended && category == fcNaN && + if (&fromSemantics == &semX87DoubleExtended && + &toSemantics != &semX87DoubleExtended && category == fcNaN && (!(*significandParts() & 0x8000000000000000ULL) || !(*significandParts() & 0x4000000000000000ULL))) { // x86 has some unusual NaNs which cannot be represented in any other @@ -1992,7 +2014,7 @@ // For x87 extended precision, we want to make a NaN, not a special NaN if // the input wasn't special either. - if (!X86SpecialNan && semantics == &IEEEFloat::x87DoubleExtended) + if (!X86SpecialNan && semantics == &semX87DoubleExtended) APInt::tcSetBit(significandParts(), semantics->precision - 1); // gcc forces the Quiet bit on, which means (float)(double)(float_sNan) @@ -2794,7 +2816,7 @@ // the actual IEEE respresentations. We compensate for that here. APInt IEEEFloat::convertF80LongDoubleAPFloatToAPInt() const { - assert(semantics == (const llvm::fltSemantics*)&x87DoubleExtended); + assert(semantics == (const llvm::fltSemantics*)&semX87DoubleExtended); assert(partCount()==2); uint64_t myexponent, mysignificand; @@ -2824,7 +2846,7 @@ } APInt IEEEFloat::convertPPCDoubleDoubleAPFloatToAPInt() const { - assert(semantics == (const llvm::fltSemantics *)&PPCDoubleDoubleImpl); + assert(semantics == (const llvm::fltSemantics *)&semPPCDoubleDoubleImpl); assert(partCount()==2); uint64_t words[2]; @@ -2838,14 +2860,14 @@ // Declare fltSemantics before APFloat that uses it (and // saves pointer to it) to ensure correct destruction order. fltSemantics extendedSemantics = *semantics; - extendedSemantics.minExponent = IEEEdouble.minExponent; + extendedSemantics.minExponent = semIEEEdouble.minExponent; IEEEFloat extended(*this); fs = extended.convert(extendedSemantics, rmNearestTiesToEven, &losesInfo); assert(fs == opOK && !losesInfo); (void)fs; IEEEFloat u(extended); - fs = u.convert(IEEEdouble, rmNearestTiesToEven, &losesInfo); + fs = u.convert(semIEEEdouble, rmNearestTiesToEven, &losesInfo); assert(fs == opOK || fs == opInexact); (void)fs; words[0] = *u.convertDoubleAPFloatToAPInt().getRawData(); @@ -2861,7 +2883,7 @@ IEEEFloat v(extended); v.subtract(u, rmNearestTiesToEven); - fs = v.convert(IEEEdouble, rmNearestTiesToEven, &losesInfo); + fs = v.convert(semIEEEdouble, rmNearestTiesToEven, &losesInfo); assert(fs == opOK && !losesInfo); (void)fs; words[1] = *v.convertDoubleAPFloatToAPInt().getRawData(); @@ -2873,7 +2895,7 @@ } APInt IEEEFloat::convertQuadrupleAPFloatToAPInt() const { - assert(semantics == (const llvm::fltSemantics*)&IEEEquad); + assert(semantics == (const llvm::fltSemantics*)&semIEEEquad); assert(partCount()==2); uint64_t myexponent, mysignificand, mysignificand2; @@ -2907,7 +2929,7 @@ } APInt IEEEFloat::convertDoubleAPFloatToAPInt() const { - assert(semantics == (const llvm::fltSemantics*)&IEEEdouble); + assert(semantics == (const llvm::fltSemantics*)&semIEEEdouble); assert(partCount()==1); uint64_t myexponent, mysignificand; @@ -2935,7 +2957,7 @@ } APInt IEEEFloat::convertFloatAPFloatToAPInt() const { - assert(semantics == (const llvm::fltSemantics*)&IEEEsingle); + assert(semantics == (const llvm::fltSemantics*)&semIEEEsingle); assert(partCount()==1); uint32_t myexponent, mysignificand; @@ -2962,7 +2984,7 @@ } APInt IEEEFloat::convertHalfAPFloatToAPInt() const { - assert(semantics == (const llvm::fltSemantics*)&IEEEhalf); + assert(semantics == (const llvm::fltSemantics*)&semIEEEhalf); assert(partCount()==1); uint32_t myexponent, mysignificand; @@ -2993,35 +3015,35 @@ // and treating the result as a normal integer is unlikely to be useful. APInt IEEEFloat::bitcastToAPInt() const { - if (semantics == (const llvm::fltSemantics*)&IEEEhalf) + if (semantics == (const llvm::fltSemantics*)&semIEEEhalf) return convertHalfAPFloatToAPInt(); - if (semantics == (const llvm::fltSemantics*)&IEEEsingle) + if (semantics == (const llvm::fltSemantics*)&semIEEEsingle) return convertFloatAPFloatToAPInt(); - if (semantics == (const llvm::fltSemantics*)&IEEEdouble) + if (semantics == (const llvm::fltSemantics*)&semIEEEdouble) return convertDoubleAPFloatToAPInt(); - if (semantics == (const llvm::fltSemantics*)&IEEEquad) + if (semantics == (const llvm::fltSemantics*)&semIEEEquad) return convertQuadrupleAPFloatToAPInt(); - if (semantics == (const llvm::fltSemantics *)&PPCDoubleDoubleImpl) + if (semantics == (const llvm::fltSemantics *)&semPPCDoubleDoubleImpl) return convertPPCDoubleDoubleAPFloatToAPInt(); - assert(semantics == (const llvm::fltSemantics*)&x87DoubleExtended && + assert(semantics == (const llvm::fltSemantics*)&semX87DoubleExtended && "unknown format!"); return convertF80LongDoubleAPFloatToAPInt(); } float IEEEFloat::convertToFloat() const { - assert(semantics == (const llvm::fltSemantics*)&IEEEsingle && + assert(semantics == (const llvm::fltSemantics*)&semIEEEsingle && "Float semantics are not IEEEsingle"); APInt api = bitcastToAPInt(); return api.bitsToFloat(); } double IEEEFloat::convertToDouble() const { - assert(semantics == (const llvm::fltSemantics*)&IEEEdouble && + assert(semantics == (const llvm::fltSemantics*)&semIEEEdouble && "Float semantics are not IEEEdouble"); APInt api = bitcastToAPInt(); return api.bitsToDouble(); @@ -3041,7 +3063,7 @@ uint64_t myexponent = (i2 & 0x7fff); uint64_t mysignificand = i1; - initialize(&IEEEFloat::x87DoubleExtended); + initialize(&semX87DoubleExtended); assert(partCount()==2); sign = static_cast(i2>>15); @@ -3075,14 +3097,14 @@ // Get the first double and convert to our format. initFromDoubleAPInt(APInt(64, i1)); - fs = convert(PPCDoubleDoubleImpl, rmNearestTiesToEven, &losesInfo); + fs = convert(semPPCDoubleDoubleImpl, rmNearestTiesToEven, &losesInfo); assert(fs == opOK && !losesInfo); (void)fs; // Unless we have a special case, add in second double. if (isFiniteNonZero()) { - IEEEFloat v(IEEEdouble, APInt(64, i2)); - fs = v.convert(PPCDoubleDoubleImpl, rmNearestTiesToEven, &losesInfo); + IEEEFloat v(semIEEEdouble, APInt(64, i2)); + fs = v.convert(semPPCDoubleDoubleImpl, rmNearestTiesToEven, &losesInfo); assert(fs == opOK && !losesInfo); (void)fs; @@ -3098,7 +3120,7 @@ uint64_t mysignificand = i1; uint64_t mysignificand2 = i2 & 0xffffffffffffLL; - initialize(&IEEEFloat::IEEEquad); + initialize(&semIEEEquad); assert(partCount()==2); sign = static_cast(i2>>63); @@ -3134,7 +3156,7 @@ uint64_t myexponent = (i >> 52) & 0x7ff; uint64_t mysignificand = i & 0xfffffffffffffLL; - initialize(&IEEEFloat::IEEEdouble); + initialize(&semIEEEdouble); assert(partCount()==1); sign = static_cast(i>>63); @@ -3165,7 +3187,7 @@ uint32_t myexponent = (i >> 23) & 0xff; uint32_t mysignificand = i & 0x7fffff; - initialize(&IEEEFloat::IEEEsingle); + initialize(&semIEEEsingle); assert(partCount()==1); sign = i >> 31; @@ -3196,7 +3218,7 @@ uint32_t myexponent = (i >> 10) & 0x1f; uint32_t mysignificand = i & 0x3ff; - initialize(&IEEEFloat::IEEEhalf); + initialize(&semIEEEhalf); assert(partCount()==1); sign = i >> 15; @@ -3226,17 +3248,17 @@ /// isIEEE argument distinguishes between PPC128 and IEEE128 (not meaningful /// when the size is anything else). void IEEEFloat::initFromAPInt(const fltSemantics *Sem, const APInt &api) { - if (Sem == &IEEEhalf) + if (Sem == &semIEEEhalf) return initFromHalfAPInt(api); - if (Sem == &IEEEsingle) + if (Sem == &semIEEEsingle) return initFromFloatAPInt(api); - if (Sem == &IEEEdouble) + if (Sem == &semIEEEdouble) return initFromDoubleAPInt(api); - if (Sem == &x87DoubleExtended) + if (Sem == &semX87DoubleExtended) return initFromF80LongDoubleAPInt(api); - if (Sem == &IEEEquad) + if (Sem == &semIEEEquad) return initFromQuadrupleAPInt(api); - if (Sem == &PPCDoubleDoubleImpl) + if (Sem == &semPPCDoubleDoubleImpl) return initFromPPCDoubleDoubleAPInt(api); llvm_unreachable(nullptr); @@ -3299,11 +3321,11 @@ } IEEEFloat::IEEEFloat(float f) { - initFromAPInt(&IEEEsingle, APInt::floatToBits(f)); + initFromAPInt(&semIEEEsingle, APInt::floatToBits(f)); } IEEEFloat::IEEEFloat(double d) { - initFromAPInt(&IEEEdouble, APInt::doubleToBits(d)); + initFromAPInt(&semIEEEdouble, APInt::doubleToBits(d)); } namespace { @@ -3828,38 +3850,38 @@ } DoubleAPFloat::DoubleAPFloat(const fltSemantics &S) - : Semantics(&S), Floats(new APFloat[2]{APFloat(PPCDoubleDoubleImpl), - APFloat(IEEEdouble)}) { - assert(Semantics == &PPCDoubleDouble); + : Semantics(&S), Floats(new APFloat[2]{APFloat(semPPCDoubleDoubleImpl), + APFloat(semIEEEdouble)}) { + assert(Semantics == &semPPCDoubleDouble); } DoubleAPFloat::DoubleAPFloat(const fltSemantics &S, uninitializedTag) : Semantics(&S), - Floats(new APFloat[2]{APFloat(PPCDoubleDoubleImpl, uninitialized), - APFloat(IEEEdouble, uninitialized)}) { - assert(Semantics == &PPCDoubleDouble); + Floats(new APFloat[2]{APFloat(semPPCDoubleDoubleImpl, uninitialized), + APFloat(semIEEEdouble, uninitialized)}) { + assert(Semantics == &semPPCDoubleDouble); } DoubleAPFloat::DoubleAPFloat(const fltSemantics &S, integerPart I) - : Semantics(&S), Floats(new APFloat[2]{APFloat(PPCDoubleDoubleImpl, I), - APFloat(IEEEdouble)}) { - assert(Semantics == &PPCDoubleDouble); + : Semantics(&S), Floats(new APFloat[2]{APFloat(semPPCDoubleDoubleImpl, I), + APFloat(semIEEEdouble)}) { + assert(Semantics == &semPPCDoubleDouble); } DoubleAPFloat::DoubleAPFloat(const fltSemantics &S, const APInt &I) - : Semantics(&S), Floats(new APFloat[2]{APFloat(PPCDoubleDoubleImpl, I), - APFloat(IEEEdouble)}) { - assert(Semantics == &PPCDoubleDouble); + : Semantics(&S), Floats(new APFloat[2]{APFloat(semPPCDoubleDoubleImpl, I), + APFloat(semIEEEdouble)}) { + assert(Semantics == &semPPCDoubleDouble); } DoubleAPFloat::DoubleAPFloat(const fltSemantics &S, APFloat &&First, APFloat &&Second) : Semantics(&S), Floats(new APFloat[2]{std::move(First), std::move(Second)}) { - assert(Semantics == &PPCDoubleDouble); - // TODO Check for First == &IEEEdouble once the transition is done. - assert(&Floats[0].getSemantics() == &PPCDoubleDoubleImpl); - assert(&Floats[1].getSemantics() == &IEEEdouble); + assert(Semantics == &semPPCDoubleDouble); + // TODO Check for First == &semIEEEdouble once the transition is done. + assert(&Floats[0].getSemantics() == &semPPCDoubleDoubleImpl); + assert(&Floats[1].getSemantics() == &semIEEEdouble); } DoubleAPFloat::DoubleAPFloat(const DoubleAPFloat &RHS) @@ -3867,13 +3889,13 @@ Floats(RHS.Floats ? new APFloat[2]{APFloat(RHS.Floats[0]), APFloat(RHS.Floats[1])} : nullptr) { - assert(Semantics == &PPCDoubleDouble); + assert(Semantics == &semPPCDoubleDouble); } DoubleAPFloat::DoubleAPFloat(DoubleAPFloat &&RHS) : Semantics(RHS.Semantics), Floats(std::move(RHS.Floats)) { - RHS.Semantics = &Bogus; - assert(Semantics == &PPCDoubleDouble); + RHS.Semantics = &semBogus; + assert(Semantics == &semPPCDoubleDouble); } DoubleAPFloat &DoubleAPFloat::operator=(const DoubleAPFloat &RHS) { @@ -3895,7 +3917,7 @@ } else if (usesLayout(Semantics)) { new (&Double) DoubleAPFloat(Semantics, APFloat(std::move(F), F.getSemantics()), - APFloat(IEEEdouble)); + APFloat(semIEEEdouble)); } else { llvm_unreachable("Unexpected semantics"); } @@ -3921,10 +3943,10 @@ return U.IEEE.convert(ToSemantics, RM, losesInfo); } else if (usesLayout(getSemantics()) && usesLayout(ToSemantics)) { - assert(&ToSemantics == &PPCDoubleDouble); - auto Ret = U.IEEE.convert(PPCDoubleDoubleImpl, RM, losesInfo); + assert(&ToSemantics == &semPPCDoubleDouble); + auto Ret = U.IEEE.convert(semPPCDoubleDoubleImpl, RM, losesInfo); *this = APFloat( - DoubleAPFloat(PPCDoubleDouble, std::move(*this), APFloat(IEEEdouble)), + DoubleAPFloat(semPPCDoubleDouble, std::move(*this), APFloat(semIEEEdouble)), ToSemantics); return Ret; } else if (usesLayout(getSemantics()) && @@ -3941,21 +3963,21 @@ if (isIEEE) { switch (BitWidth) { case 16: - return APFloat(IEEEhalf, APInt::getAllOnesValue(BitWidth)); + return APFloat(semIEEEhalf, APInt::getAllOnesValue(BitWidth)); case 32: - return APFloat(IEEEsingle, APInt::getAllOnesValue(BitWidth)); + return APFloat(semIEEEsingle, APInt::getAllOnesValue(BitWidth)); case 64: - return APFloat(IEEEdouble, APInt::getAllOnesValue(BitWidth)); + return APFloat(semIEEEdouble, APInt::getAllOnesValue(BitWidth)); case 80: - return APFloat(x87DoubleExtended, APInt::getAllOnesValue(BitWidth)); + return APFloat(semX87DoubleExtended, APInt::getAllOnesValue(BitWidth)); case 128: - return APFloat(IEEEquad, APInt::getAllOnesValue(BitWidth)); + return APFloat(semIEEEquad, APInt::getAllOnesValue(BitWidth)); default: llvm_unreachable("Unknown floating bit width"); } } else { assert(BitWidth == 128); - return APFloat(PPCDoubleDouble, APInt::getAllOnesValue(BitWidth)); + return APFloat(semPPCDoubleDouble, APInt::getAllOnesValue(BitWidth)); } } Index: lib/Support/ScaledNumber.cpp =================================================================== --- lib/Support/ScaledNumber.cpp +++ lib/Support/ScaledNumber.cpp @@ -183,7 +183,7 @@ // Build the float and print it. uint64_t RawBits[2] = {D, AdjustedE}; - APFloat Float(APFloat::x87DoubleExtended, APInt(80, RawBits)); + APFloat Float(APFloat::x87DoubleExtended(), APInt(80, RawBits)); SmallVector Chars; Float.toString(Chars, Precision, 0); return std::string(Chars.begin(), Chars.end()); Index: lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp =================================================================== --- lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -2206,7 +2206,7 @@ const AsmToken &Tok = Parser.getTok(); if (Tok.is(AsmToken::Real)) { - APFloat RealVal(APFloat::IEEEdouble, Tok.getString()); + APFloat RealVal(APFloat::IEEEdouble(), Tok.getString()); if (isNegative) RealVal.changeSign(); @@ -2232,7 +2232,7 @@ return MatchOperand_ParseFail; } } else { - APFloat RealVal(APFloat::IEEEdouble, Tok.getString()); + APFloat RealVal(APFloat::IEEEdouble(), Tok.getString()); uint64_t IntVal = RealVal.bitcastToAPInt().getZExtValue(); // If we had a '-' in front, toggle the sign bit. IntVal ^= (uint64_t)isNegative << 63; @@ -3154,7 +3154,7 @@ // so convert the value. const AsmToken &Tok = Parser.getTok(); if (Tok.is(AsmToken::Real)) { - APFloat RealVal(APFloat::IEEEdouble, Tok.getString()); + APFloat RealVal(APFloat::IEEEdouble(), Tok.getString()); uint64_t IntVal = RealVal.bitcastToAPInt().getZExtValue(); if (Mnemonic != "fcmp" && Mnemonic != "fcmpe" && Mnemonic != "fcmeq" && Mnemonic != "fcmge" && Mnemonic != "fcmgt" && Mnemonic != "fcmle" && Index: lib/Target/AMDGPU/AMDGPUISelLowering.cpp =================================================================== --- lib/Target/AMDGPU/AMDGPUISelLowering.cpp +++ lib/Target/AMDGPU/AMDGPUISelLowering.cpp @@ -1609,7 +1609,7 @@ assert(Op.getValueType() == MVT::f64); - APFloat C1Val(APFloat::IEEEdouble, "0x1.0p+52"); + APFloat C1Val(APFloat::IEEEdouble(), "0x1.0p+52"); SDValue C1 = DAG.getConstantFP(C1Val, SL, MVT::f64); SDValue CopySign = DAG.getNode(ISD::FCOPYSIGN, SL, MVT::f64, C1, Src); @@ -1620,7 +1620,7 @@ SDValue Fabs = DAG.getNode(ISD::FABS, SL, MVT::f64, Src); - APFloat C2Val(APFloat::IEEEdouble, "0x1.fffffffffffffp+51"); + APFloat C2Val(APFloat::IEEEdouble(), "0x1.fffffffffffffp+51"); SDValue C2 = DAG.getConstantFP(C2Val, SL, MVT::f64); EVT SetCCVT = Index: lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp =================================================================== --- lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp +++ lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp @@ -800,9 +800,9 @@ return AMDGPU::isInlinableLiteral64(Imm.Val, AsmParser->isVI()); } else { // Expected 32-bit operand bool lost; - APFloat FPLiteral(APFloat::IEEEdouble, Literal); + APFloat FPLiteral(APFloat::IEEEdouble(), Literal); // Convert literal to single precision - APFloat::opStatus status = FPLiteral.convert(APFloat::IEEEsingle, + APFloat::opStatus status = FPLiteral.convert(APFloat::IEEEsingle(), APFloat::rmNearestTiesToEven, &lost); // We allow precision lost but not overflow or underflow @@ -847,9 +847,9 @@ return false; } else { // Expected 32-bit operand bool lost; - APFloat FPLiteral(APFloat::IEEEdouble, Literal); + APFloat FPLiteral(APFloat::IEEEdouble(), Literal); // Convert literal to single precision - APFloat::opStatus status = FPLiteral.convert(APFloat::IEEEsingle, + APFloat::opStatus status = FPLiteral.convert(APFloat::IEEEsingle(), APFloat::rmNearestTiesToEven, &lost); // We allow precision lost but not overflow or underflow @@ -931,9 +931,9 @@ } } else { // Expected 32-bit operand bool lost; - APFloat FPLiteral(APFloat::IEEEdouble, Literal); + APFloat FPLiteral(APFloat::IEEEdouble(), Literal); // Convert literal to single precision - FPLiteral.convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven, &lost); + FPLiteral.convert(APFloat::IEEEsingle(), APFloat::rmNearestTiesToEven, &lost); // We allow precision lost but not overflow or underflow. This should be // checked earlier in isLiteralImm() Inst.addOperand(MCOperand::createImm(FPLiteral.bitcastToAPInt().getZExtValue())); @@ -960,8 +960,8 @@ APInt Literal(64, Imm.Val); if (Imm.IsFPImm) { // We got fp literal bool lost; - APFloat FPLiteral(APFloat::IEEEdouble, Literal); - FPLiteral.convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven, &lost); + APFloat FPLiteral(APFloat::IEEEdouble(), Literal); + FPLiteral.convert(APFloat::IEEEsingle(), APFloat::rmNearestTiesToEven, &lost); Inst.addOperand(MCOperand::createImm(FPLiteral.bitcastToAPInt().getZExtValue())); } else { // We got int literal token Inst.addOperand(MCOperand::createImm(Literal.getLoBits(32).getZExtValue())); Index: lib/Target/ARM/ARMMCInstLower.cpp =================================================================== --- lib/Target/ARM/ARMMCInstLower.cpp +++ lib/Target/ARM/ARMMCInstLower.cpp @@ -98,7 +98,7 @@ case MachineOperand::MO_FPImmediate: { APFloat Val = MO.getFPImm()->getValueAPF(); bool ignored; - Val.convert(APFloat::IEEEdouble, APFloat::rmTowardZero, &ignored); + Val.convert(APFloat::IEEEdouble(), APFloat::rmTowardZero, &ignored); MCOp = MCOperand::createFPImm(Val.convertToDouble()); break; } Index: lib/Target/ARM/AsmParser/ARMAsmParser.cpp =================================================================== --- lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -5294,7 +5294,7 @@ const AsmToken &Tok = Parser.getTok(); SMLoc Loc = Tok.getLoc(); if (Tok.is(AsmToken::Real) && isVmovf) { - APFloat RealVal(APFloat::IEEEsingle, Tok.getString()); + APFloat RealVal(APFloat::IEEEsingle(), Tok.getString()); uint64_t IntVal = RealVal.bitcastToAPInt().getZExtValue(); // If we had a '-' in front, toggle the sign bit. IntVal ^= (uint64_t)isNegative << 31; Index: lib/Target/NVPTX/NVPTXAsmPrinter.cpp =================================================================== --- lib/Target/NVPTX/NVPTXAsmPrinter.cpp +++ lib/Target/NVPTX/NVPTXAsmPrinter.cpp @@ -1723,11 +1723,11 @@ if (Fp->getType()->getTypeID() == Type::FloatTyID) { numHex = 8; lead = "0f"; - APF.convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven, &ignored); + APF.convert(APFloat::IEEEsingle(), APFloat::rmNearestTiesToEven, &ignored); } else if (Fp->getType()->getTypeID() == Type::DoubleTyID) { numHex = 16; lead = "0d"; - APF.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven, &ignored); + APF.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven, &ignored); } else llvm_unreachable("unsupported fp type"); Index: lib/Target/NVPTX/NVPTXInstrInfo.td =================================================================== --- lib/Target/NVPTX/NVPTXInstrInfo.td +++ lib/Target/NVPTX/NVPTXInstrInfo.td @@ -739,12 +739,12 @@ // Constant 1.0f def FloatConst1 : PatLeaf<(fpimm), [{ - return &N->getValueAPF().getSemantics() == &llvm::APFloat::IEEEsingle && + return &N->getValueAPF().getSemantics() == &llvm::APFloat::IEEEsingle() && N->getValueAPF().convertToFloat() == 1.0f; }]>; // Constant 1.0 (double) def DoubleConst1 : PatLeaf<(fpimm), [{ - return &N->getValueAPF().getSemantics() == &llvm::APFloat::IEEEdouble && + return &N->getValueAPF().getSemantics() == &llvm::APFloat::IEEEdouble() && N->getValueAPF().convertToDouble() == 1.0; }]>; Index: lib/Target/NVPTX/NVPTXMCExpr.cpp =================================================================== --- lib/Target/NVPTX/NVPTXMCExpr.cpp +++ lib/Target/NVPTX/NVPTXMCExpr.cpp @@ -30,12 +30,12 @@ case VK_NVPTX_SINGLE_PREC_FLOAT: OS << "0f"; NumHex = 8; - APF.convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven, &Ignored); + APF.convert(APFloat::IEEEsingle(), APFloat::rmNearestTiesToEven, &Ignored); break; case VK_NVPTX_DOUBLE_PREC_FLOAT: OS << "0d"; NumHex = 16; - APF.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven, &Ignored); + APF.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven, &Ignored); break; } Index: lib/Target/X86/X86ISelLowering.cpp =================================================================== --- lib/Target/X86/X86ISelLowering.cpp +++ lib/Target/X86/X86ISelLowering.cpp @@ -599,14 +599,14 @@ setOperationAction(ISD::UNDEF, MVT::f80, Expand); setOperationAction(ISD::FCOPYSIGN, MVT::f80, Expand); { - APFloat TmpFlt = APFloat::getZero(APFloat::x87DoubleExtended); + APFloat TmpFlt = APFloat::getZero(APFloat::x87DoubleExtended()); addLegalFPImmediate(TmpFlt); // FLD0 TmpFlt.changeSign(); addLegalFPImmediate(TmpFlt); // FLD0/FCHS bool ignored; APFloat TmpFlt2(+1.0); - TmpFlt2.convert(APFloat::x87DoubleExtended, APFloat::rmNearestTiesToEven, + TmpFlt2.convert(APFloat::x87DoubleExtended(), APFloat::rmNearestTiesToEven, &ignored); addLegalFPImmediate(TmpFlt2); // FLD1 TmpFlt2.changeSign(); @@ -13844,10 +13844,10 @@ SmallVector CV1; CV1.push_back( - ConstantFP::get(*Context, APFloat(APFloat::IEEEdouble, + ConstantFP::get(*Context, APFloat(APFloat::IEEEdouble(), APInt(64, 0x4330000000000000ULL)))); CV1.push_back( - ConstantFP::get(*Context, APFloat(APFloat::IEEEdouble, + ConstantFP::get(*Context, APFloat(APFloat::IEEEdouble(), APInt(64, 0x4530000000000000ULL)))); Constant *C1 = ConstantVector::get(CV1); SDValue CPIdx1 = DAG.getConstantPool(C1, PtrVT, 16); @@ -14014,7 +14014,7 @@ // Create the vector constant for -(0x1.0p39f + 0x1.0p23f). SDValue VecCstFAdd = DAG.getConstantFP( - APFloat(APFloat::IEEEsingle, APInt(32, 0xD3000080)), DL, VecFloatVT); + APFloat(APFloat::IEEEsingle(), APInt(32, 0xD3000080)), DL, VecFloatVT); // float4 fhi = (float4) hi - (0x1.0p39f + 0x1.0p23f); SDValue HighBitcast = DAG.getBitcast(VecFloatVT, High); @@ -14258,15 +14258,15 @@ // For X87 we'd like to use the smallest FP type for this constant, but // for DAG type consistency we have to match the FP operand type. - APFloat Thresh(APFloat::IEEEsingle, APInt(32, 0x5f000000)); + APFloat Thresh(APFloat::IEEEsingle(), APInt(32, 0x5f000000)); LLVM_ATTRIBUTE_UNUSED APFloat::opStatus Status = APFloat::opOK; bool LosesInfo = false; if (TheVT == MVT::f64) // The rounding mode is irrelevant as the conversion should be exact. - Status = Thresh.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven, + Status = Thresh.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven, &LosesInfo); else if (TheVT == MVT::f80) - Status = Thresh.convert(APFloat::x87DoubleExtended, + Status = Thresh.convert(APFloat::x87DoubleExtended(), APFloat::rmNearestTiesToEven, &LosesInfo); assert(Status == APFloat::opOK && !LosesInfo && @@ -14816,8 +14816,8 @@ APInt MaskElt = IsFABS ? APInt::getSignedMaxValue(EltBits) : APInt::getSignBit(EltBits); const fltSemantics &Sem = - EltVT == MVT::f64 ? APFloat::IEEEdouble : - (IsF128 ? APFloat::IEEEquad : APFloat::IEEEsingle); + EltVT == MVT::f64 ? APFloat::IEEEdouble() : + (IsF128 ? APFloat::IEEEquad() : APFloat::IEEEsingle()); SDValue Mask = DAG.getConstantFP(APFloat(Sem, MaskElt), dl, LogicVT); SDValue Op0 = Op.getOperand(0); @@ -14861,8 +14861,8 @@ MVT EltVT = VT.getScalarType(); const fltSemantics &Sem = - EltVT == MVT::f64 ? APFloat::IEEEdouble - : (IsF128 ? APFloat::IEEEquad : APFloat::IEEEsingle); + EltVT == MVT::f64 ? APFloat::IEEEdouble() + : (IsF128 ? APFloat::IEEEquad() : APFloat::IEEEsingle()); // Perform all scalar logic operations as 16-byte vectors because there are no // scalar FP logic instructions in SSE. Index: lib/Transforms/InstCombine/InstCombineCasts.cpp =================================================================== --- lib/Transforms/InstCombine/InstCombineCasts.cpp +++ lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -1227,14 +1227,14 @@ if (CFP->getType() == Type::getPPC_FP128Ty(V->getContext())) return V; // No constant folding of this. // See if the value can be truncated to half and then reextended. - if (Value *V = fitsInFPType(CFP, APFloat::IEEEhalf)) + if (Value *V = fitsInFPType(CFP, APFloat::IEEEhalf())) return V; // See if the value can be truncated to float and then reextended. - if (Value *V = fitsInFPType(CFP, APFloat::IEEEsingle)) + if (Value *V = fitsInFPType(CFP, APFloat::IEEEsingle())) return V; if (CFP->getType()->isDoubleTy()) return V; // Won't shrink. - if (Value *V = fitsInFPType(CFP, APFloat::IEEEdouble)) + if (Value *V = fitsInFPType(CFP, APFloat::IEEEdouble())) return V; // Don't try to shrink to various long double types. } Index: lib/Transforms/InstCombine/InstCombineCompares.cpp =================================================================== --- lib/Transforms/InstCombine/InstCombineCompares.cpp +++ lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -4661,17 +4661,17 @@ const fltSemantics *Sem; // FIXME: This shouldn't be here. if (LHSExt->getSrcTy()->isHalfTy()) - Sem = &APFloat::IEEEhalf; + Sem = &APFloat::IEEEhalf(); else if (LHSExt->getSrcTy()->isFloatTy()) - Sem = &APFloat::IEEEsingle; + Sem = &APFloat::IEEEsingle(); else if (LHSExt->getSrcTy()->isDoubleTy()) - Sem = &APFloat::IEEEdouble; + Sem = &APFloat::IEEEdouble(); else if (LHSExt->getSrcTy()->isFP128Ty()) - Sem = &APFloat::IEEEquad; + Sem = &APFloat::IEEEquad(); else if (LHSExt->getSrcTy()->isX86_FP80Ty()) - Sem = &APFloat::x87DoubleExtended; + Sem = &APFloat::x87DoubleExtended(); else if (LHSExt->getSrcTy()->isPPC_FP128Ty()) - Sem = &APFloat::PPCDoubleDouble; + Sem = &APFloat::PPCDoubleDouble(); else break; Index: lib/Transforms/Utils/SimplifyLibCalls.cpp =================================================================== --- lib/Transforms/Utils/SimplifyLibCalls.cpp +++ lib/Transforms/Utils/SimplifyLibCalls.cpp @@ -900,7 +900,7 @@ if (ConstantFP *Const = dyn_cast(Val)) { APFloat F = Const->getValueAPF(); bool losesInfo; - (void)F.convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven, + (void)F.convert(APFloat::IEEEsingle(), APFloat::rmNearestTiesToEven, &losesInfo); if (!losesInfo) return ConstantFP::get(Const->getContext(), F); @@ -1129,7 +1129,7 @@ // We cannot readily convert a non-double type (like float) to a double. // So we first convert V to something which could be converted to double. bool ignored; - V.convert(APFloat::IEEEdouble, APFloat::rmTowardZero, &ignored); + V.convert(APFloat::IEEEdouble(), APFloat::rmTowardZero, &ignored); // TODO: Should the new instructions propagate the 'fast' flag of the pow()? Value *FMul = getPow(InnerChain, V.convertToDouble(), B); Index: unittests/ADT/APFloatTest.cpp =================================================================== --- unittests/ADT/APFloatTest.cpp +++ unittests/ADT/APFloatTest.cpp @@ -38,20 +38,20 @@ // positive/negative distinction is included only since the getQNaN/getSNaN // API provides the option. APInt payload = APInt::getOneBitSet(4, 2); - EXPECT_FALSE(APFloat::getQNaN(APFloat::IEEEsingle, false).isSignaling()); - EXPECT_FALSE(APFloat::getQNaN(APFloat::IEEEsingle, true).isSignaling()); - EXPECT_FALSE(APFloat::getQNaN(APFloat::IEEEsingle, false, &payload).isSignaling()); - EXPECT_FALSE(APFloat::getQNaN(APFloat::IEEEsingle, true, &payload).isSignaling()); - EXPECT_TRUE(APFloat::getSNaN(APFloat::IEEEsingle, false).isSignaling()); - EXPECT_TRUE(APFloat::getSNaN(APFloat::IEEEsingle, true).isSignaling()); - EXPECT_TRUE(APFloat::getSNaN(APFloat::IEEEsingle, false, &payload).isSignaling()); - EXPECT_TRUE(APFloat::getSNaN(APFloat::IEEEsingle, true, &payload).isSignaling()); + EXPECT_FALSE(APFloat::getQNaN(APFloat::IEEEsingle(), false).isSignaling()); + EXPECT_FALSE(APFloat::getQNaN(APFloat::IEEEsingle(), true).isSignaling()); + EXPECT_FALSE(APFloat::getQNaN(APFloat::IEEEsingle(), false, &payload).isSignaling()); + EXPECT_FALSE(APFloat::getQNaN(APFloat::IEEEsingle(), true, &payload).isSignaling()); + EXPECT_TRUE(APFloat::getSNaN(APFloat::IEEEsingle(), false).isSignaling()); + EXPECT_TRUE(APFloat::getSNaN(APFloat::IEEEsingle(), true).isSignaling()); + EXPECT_TRUE(APFloat::getSNaN(APFloat::IEEEsingle(), false, &payload).isSignaling()); + EXPECT_TRUE(APFloat::getSNaN(APFloat::IEEEsingle(), true, &payload).isSignaling()); } TEST(APFloatTest, next) { - APFloat test(APFloat::IEEEquad, APFloat::uninitialized); - APFloat expected(APFloat::IEEEquad, APFloat::uninitialized); + APFloat test(APFloat::IEEEquad(), APFloat::uninitialized); + APFloat expected(APFloat::IEEEquad(), APFloat::uninitialized); // 1. Test Special Cases Values. // @@ -69,37 +69,37 @@ // 10. -0 // nextUp(+inf) = +inf. - test = APFloat::getInf(APFloat::IEEEquad, false); - expected = APFloat::getInf(APFloat::IEEEquad, false); + test = APFloat::getInf(APFloat::IEEEquad(), false); + expected = APFloat::getInf(APFloat::IEEEquad(), false); EXPECT_EQ(test.next(false), APFloat::opOK); EXPECT_TRUE(test.isInfinity()); EXPECT_TRUE(!test.isNegative()); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextDown(+inf) = -nextUp(-inf) = -(-getLargest()) = getLargest() - test = APFloat::getInf(APFloat::IEEEquad, false); - expected = APFloat::getLargest(APFloat::IEEEquad, false); + test = APFloat::getInf(APFloat::IEEEquad(), false); + expected = APFloat::getLargest(APFloat::IEEEquad(), false); EXPECT_EQ(test.next(true), APFloat::opOK); EXPECT_TRUE(!test.isNegative()); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextUp(-inf) = -getLargest() - test = APFloat::getInf(APFloat::IEEEquad, true); - expected = APFloat::getLargest(APFloat::IEEEquad, true); + test = APFloat::getInf(APFloat::IEEEquad(), true); + expected = APFloat::getLargest(APFloat::IEEEquad(), true); EXPECT_EQ(test.next(false), APFloat::opOK); EXPECT_TRUE(test.isNegative()); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextDown(-inf) = -nextUp(+inf) = -(+inf) = -inf. - test = APFloat::getInf(APFloat::IEEEquad, true); - expected = APFloat::getInf(APFloat::IEEEquad, true); + test = APFloat::getInf(APFloat::IEEEquad(), true); + expected = APFloat::getInf(APFloat::IEEEquad(), true); EXPECT_EQ(test.next(true), APFloat::opOK); EXPECT_TRUE(test.isInfinity() && test.isNegative()); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextUp(getLargest()) = +inf - test = APFloat::getLargest(APFloat::IEEEquad, false); - expected = APFloat::getInf(APFloat::IEEEquad, false); + test = APFloat::getLargest(APFloat::IEEEquad(), false); + expected = APFloat::getInf(APFloat::IEEEquad(), false); EXPECT_EQ(test.next(false), APFloat::opOK); EXPECT_TRUE(test.isInfinity() && !test.isNegative()); EXPECT_TRUE(test.bitwiseIsEqual(expected)); @@ -107,100 +107,100 @@ // nextDown(getLargest()) = -nextUp(-getLargest()) // = -(-getLargest() + inc) // = getLargest() - inc. - test = APFloat::getLargest(APFloat::IEEEquad, false); - expected = APFloat(APFloat::IEEEquad, + test = APFloat::getLargest(APFloat::IEEEquad(), false); + expected = APFloat(APFloat::IEEEquad(), "0x1.fffffffffffffffffffffffffffep+16383"); EXPECT_EQ(test.next(true), APFloat::opOK); EXPECT_TRUE(!test.isInfinity() && !test.isNegative()); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextUp(-getLargest()) = -getLargest() + inc. - test = APFloat::getLargest(APFloat::IEEEquad, true); - expected = APFloat(APFloat::IEEEquad, + test = APFloat::getLargest(APFloat::IEEEquad(), true); + expected = APFloat(APFloat::IEEEquad(), "-0x1.fffffffffffffffffffffffffffep+16383"); EXPECT_EQ(test.next(false), APFloat::opOK); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextDown(-getLargest()) = -nextUp(getLargest()) = -(inf) = -inf. - test = APFloat::getLargest(APFloat::IEEEquad, true); - expected = APFloat::getInf(APFloat::IEEEquad, true); + test = APFloat::getLargest(APFloat::IEEEquad(), true); + expected = APFloat::getInf(APFloat::IEEEquad(), true); EXPECT_EQ(test.next(true), APFloat::opOK); EXPECT_TRUE(test.isInfinity() && test.isNegative()); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextUp(getSmallest()) = getSmallest() + inc. - test = APFloat(APFloat::IEEEquad, "0x0.0000000000000000000000000001p-16382"); - expected = APFloat(APFloat::IEEEquad, + test = APFloat(APFloat::IEEEquad(), "0x0.0000000000000000000000000001p-16382"); + expected = APFloat(APFloat::IEEEquad(), "0x0.0000000000000000000000000002p-16382"); EXPECT_EQ(test.next(false), APFloat::opOK); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextDown(getSmallest()) = -nextUp(-getSmallest()) = -(-0) = +0. - test = APFloat(APFloat::IEEEquad, "0x0.0000000000000000000000000001p-16382"); - expected = APFloat::getZero(APFloat::IEEEquad, false); + test = APFloat(APFloat::IEEEquad(), "0x0.0000000000000000000000000001p-16382"); + expected = APFloat::getZero(APFloat::IEEEquad(), false); EXPECT_EQ(test.next(true), APFloat::opOK); EXPECT_TRUE(test.isPosZero()); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextUp(-getSmallest()) = -0. - test = APFloat(APFloat::IEEEquad, "-0x0.0000000000000000000000000001p-16382"); - expected = APFloat::getZero(APFloat::IEEEquad, true); + test = APFloat(APFloat::IEEEquad(), "-0x0.0000000000000000000000000001p-16382"); + expected = APFloat::getZero(APFloat::IEEEquad(), true); EXPECT_EQ(test.next(false), APFloat::opOK); EXPECT_TRUE(test.isNegZero()); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextDown(-getSmallest()) = -nextUp(getSmallest()) = -getSmallest() - inc. - test = APFloat(APFloat::IEEEquad, "-0x0.0000000000000000000000000001p-16382"); - expected = APFloat(APFloat::IEEEquad, + test = APFloat(APFloat::IEEEquad(), "-0x0.0000000000000000000000000001p-16382"); + expected = APFloat(APFloat::IEEEquad(), "-0x0.0000000000000000000000000002p-16382"); EXPECT_EQ(test.next(true), APFloat::opOK); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextUp(qNaN) = qNaN - test = APFloat::getQNaN(APFloat::IEEEquad, false); - expected = APFloat::getQNaN(APFloat::IEEEquad, false); + test = APFloat::getQNaN(APFloat::IEEEquad(), false); + expected = APFloat::getQNaN(APFloat::IEEEquad(), false); EXPECT_EQ(test.next(false), APFloat::opOK); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextDown(qNaN) = qNaN - test = APFloat::getQNaN(APFloat::IEEEquad, false); - expected = APFloat::getQNaN(APFloat::IEEEquad, false); + test = APFloat::getQNaN(APFloat::IEEEquad(), false); + expected = APFloat::getQNaN(APFloat::IEEEquad(), false); EXPECT_EQ(test.next(true), APFloat::opOK); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextUp(sNaN) = qNaN - test = APFloat::getSNaN(APFloat::IEEEquad, false); - expected = APFloat::getQNaN(APFloat::IEEEquad, false); + test = APFloat::getSNaN(APFloat::IEEEquad(), false); + expected = APFloat::getQNaN(APFloat::IEEEquad(), false); EXPECT_EQ(test.next(false), APFloat::opInvalidOp); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextDown(sNaN) = qNaN - test = APFloat::getSNaN(APFloat::IEEEquad, false); - expected = APFloat::getQNaN(APFloat::IEEEquad, false); + test = APFloat::getSNaN(APFloat::IEEEquad(), false); + expected = APFloat::getQNaN(APFloat::IEEEquad(), false); EXPECT_EQ(test.next(true), APFloat::opInvalidOp); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextUp(+0) = +getSmallest() - test = APFloat::getZero(APFloat::IEEEquad, false); - expected = APFloat::getSmallest(APFloat::IEEEquad, false); + test = APFloat::getZero(APFloat::IEEEquad(), false); + expected = APFloat::getSmallest(APFloat::IEEEquad(), false); EXPECT_EQ(test.next(false), APFloat::opOK); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextDown(+0) = -nextUp(-0) = -getSmallest() - test = APFloat::getZero(APFloat::IEEEquad, false); - expected = APFloat::getSmallest(APFloat::IEEEquad, true); + test = APFloat::getZero(APFloat::IEEEquad(), false); + expected = APFloat::getSmallest(APFloat::IEEEquad(), true); EXPECT_EQ(test.next(true), APFloat::opOK); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextUp(-0) = +getSmallest() - test = APFloat::getZero(APFloat::IEEEquad, true); - expected = APFloat::getSmallest(APFloat::IEEEquad, false); + test = APFloat::getZero(APFloat::IEEEquad(), true); + expected = APFloat::getSmallest(APFloat::IEEEquad(), false); EXPECT_EQ(test.next(false), APFloat::opOK); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextDown(-0) = -nextUp(0) = -getSmallest() - test = APFloat::getZero(APFloat::IEEEquad, true); - expected = APFloat::getSmallest(APFloat::IEEEquad, true); + test = APFloat::getZero(APFloat::IEEEquad(), true); + expected = APFloat::getSmallest(APFloat::IEEEquad(), true); EXPECT_EQ(test.next(true), APFloat::opOK); EXPECT_TRUE(test.bitwiseIsEqual(expected)); @@ -213,35 +213,35 @@ // * nextDown(+Smallest Normal) -> +Largest Denormal. // nextUp(+Largest Denormal) -> +Smallest Normal. - test = APFloat(APFloat::IEEEquad, "0x0.ffffffffffffffffffffffffffffp-16382"); - expected = APFloat(APFloat::IEEEquad, + test = APFloat(APFloat::IEEEquad(), "0x0.ffffffffffffffffffffffffffffp-16382"); + expected = APFloat(APFloat::IEEEquad(), "0x1.0000000000000000000000000000p-16382"); EXPECT_EQ(test.next(false), APFloat::opOK); EXPECT_FALSE(test.isDenormal()); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextDown(-Largest Denormal) -> -Smallest Normal. - test = APFloat(APFloat::IEEEquad, + test = APFloat(APFloat::IEEEquad(), "-0x0.ffffffffffffffffffffffffffffp-16382"); - expected = APFloat(APFloat::IEEEquad, + expected = APFloat(APFloat::IEEEquad(), "-0x1.0000000000000000000000000000p-16382"); EXPECT_EQ(test.next(true), APFloat::opOK); EXPECT_FALSE(test.isDenormal()); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextUp(-Smallest Normal) -> -LargestDenormal. - test = APFloat(APFloat::IEEEquad, + test = APFloat(APFloat::IEEEquad(), "-0x1.0000000000000000000000000000p-16382"); - expected = APFloat(APFloat::IEEEquad, + expected = APFloat(APFloat::IEEEquad(), "-0x0.ffffffffffffffffffffffffffffp-16382"); EXPECT_EQ(test.next(false), APFloat::opOK); EXPECT_TRUE(test.isDenormal()); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextDown(+Smallest Normal) -> +Largest Denormal. - test = APFloat(APFloat::IEEEquad, + test = APFloat(APFloat::IEEEquad(), "+0x1.0000000000000000000000000000p-16382"); - expected = APFloat(APFloat::IEEEquad, + expected = APFloat(APFloat::IEEEquad(), "+0x0.ffffffffffffffffffffffffffffp-16382"); EXPECT_EQ(test.next(true), APFloat::opOK); EXPECT_TRUE(test.isDenormal()); @@ -254,27 +254,27 @@ // * nextDown(-Normal Binade Boundary + 1) -> -Normal Binade Boundary. // nextUp(-Normal Binade Boundary) -> -Normal Binade Boundary + 1. - test = APFloat(APFloat::IEEEquad, "-0x1p+1"); - expected = APFloat(APFloat::IEEEquad, + test = APFloat(APFloat::IEEEquad(), "-0x1p+1"); + expected = APFloat(APFloat::IEEEquad(), "-0x1.ffffffffffffffffffffffffffffp+0"); EXPECT_EQ(test.next(false), APFloat::opOK); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextDown(+Normal Binade Boundary) -> +Normal Binade Boundary - 1. - test = APFloat(APFloat::IEEEquad, "0x1p+1"); - expected = APFloat(APFloat::IEEEquad, "0x1.ffffffffffffffffffffffffffffp+0"); + test = APFloat(APFloat::IEEEquad(), "0x1p+1"); + expected = APFloat(APFloat::IEEEquad(), "0x1.ffffffffffffffffffffffffffffp+0"); EXPECT_EQ(test.next(true), APFloat::opOK); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextUp(+Normal Binade Boundary - 1) -> +Normal Binade Boundary. - test = APFloat(APFloat::IEEEquad, "0x1.ffffffffffffffffffffffffffffp+0"); - expected = APFloat(APFloat::IEEEquad, "0x1p+1"); + test = APFloat(APFloat::IEEEquad(), "0x1.ffffffffffffffffffffffffffffp+0"); + expected = APFloat(APFloat::IEEEquad(), "0x1p+1"); EXPECT_EQ(test.next(false), APFloat::opOK); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextDown(-Normal Binade Boundary + 1) -> -Normal Binade Boundary. - test = APFloat(APFloat::IEEEquad, "-0x1.ffffffffffffffffffffffffffffp+0"); - expected = APFloat(APFloat::IEEEquad, "-0x1p+1"); + test = APFloat(APFloat::IEEEquad(), "-0x1.ffffffffffffffffffffffffffffp+0"); + expected = APFloat(APFloat::IEEEquad(), "-0x1p+1"); EXPECT_EQ(test.next(true), APFloat::opOK); EXPECT_TRUE(test.bitwiseIsEqual(expected)); @@ -290,8 +290,8 @@ // * nextDown(-Smallest Normal) -> -Smallest Normal - inc. // nextUp(-Largest Denormal) -> -Largest Denormal + inc. - test = APFloat(APFloat::IEEEquad, "-0x0.ffffffffffffffffffffffffffffp-16382"); - expected = APFloat(APFloat::IEEEquad, + test = APFloat(APFloat::IEEEquad(), "-0x0.ffffffffffffffffffffffffffffp-16382"); + expected = APFloat(APFloat::IEEEquad(), "-0x0.fffffffffffffffffffffffffffep-16382"); EXPECT_EQ(test.next(false), APFloat::opOK); EXPECT_TRUE(test.isDenormal()); @@ -299,8 +299,8 @@ EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextDown(+Largest Denormal) -> +Largest Denormal - inc. - test = APFloat(APFloat::IEEEquad, "0x0.ffffffffffffffffffffffffffffp-16382"); - expected = APFloat(APFloat::IEEEquad, + test = APFloat(APFloat::IEEEquad(), "0x0.ffffffffffffffffffffffffffffp-16382"); + expected = APFloat(APFloat::IEEEquad(), "0x0.fffffffffffffffffffffffffffep-16382"); EXPECT_EQ(test.next(true), APFloat::opOK); EXPECT_TRUE(test.isDenormal()); @@ -308,8 +308,8 @@ EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextUp(+Smallest Normal) -> +Smallest Normal + inc. - test = APFloat(APFloat::IEEEquad, "0x1.0000000000000000000000000000p-16382"); - expected = APFloat(APFloat::IEEEquad, + test = APFloat(APFloat::IEEEquad(), "0x1.0000000000000000000000000000p-16382"); + expected = APFloat(APFloat::IEEEquad(), "0x1.0000000000000000000000000001p-16382"); EXPECT_EQ(test.next(false), APFloat::opOK); EXPECT_TRUE(!test.isDenormal()); @@ -317,8 +317,8 @@ EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextDown(-Smallest Normal) -> -Smallest Normal - inc. - test = APFloat(APFloat::IEEEquad, "-0x1.0000000000000000000000000000p-16382"); - expected = APFloat(APFloat::IEEEquad, + test = APFloat(APFloat::IEEEquad(), "-0x1.0000000000000000000000000000p-16382"); + expected = APFloat(APFloat::IEEEquad(), "-0x1.0000000000000000000000000001p-16382"); EXPECT_EQ(test.next(true), APFloat::opOK); EXPECT_TRUE(!test.isDenormal()); @@ -335,28 +335,28 @@ // * nextDown(0x1p-16382) -> 0x1.ffffffffffffffffffffffffffffp-16382 // nextUp(-0x1p-16381) -> -0x1.ffffffffffffffffffffffffffffp-16382 - test = APFloat(APFloat::IEEEquad, "-0x1p-16381"); - expected = APFloat(APFloat::IEEEquad, + test = APFloat(APFloat::IEEEquad(), "-0x1p-16381"); + expected = APFloat(APFloat::IEEEquad(), "-0x1.ffffffffffffffffffffffffffffp-16382"); EXPECT_EQ(test.next(false), APFloat::opOK); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextDown(-0x1.ffffffffffffffffffffffffffffp-16382) -> // -0x1p-16381 - test = APFloat(APFloat::IEEEquad, "-0x1.ffffffffffffffffffffffffffffp-16382"); - expected = APFloat(APFloat::IEEEquad, "-0x1p-16381"); + test = APFloat(APFloat::IEEEquad(), "-0x1.ffffffffffffffffffffffffffffp-16382"); + expected = APFloat(APFloat::IEEEquad(), "-0x1p-16381"); EXPECT_EQ(test.next(true), APFloat::opOK); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextUp(0x1.ffffffffffffffffffffffffffffp-16382) -> 0x1p-16381 - test = APFloat(APFloat::IEEEquad, "0x1.ffffffffffffffffffffffffffffp-16382"); - expected = APFloat(APFloat::IEEEquad, "0x1p-16381"); + test = APFloat(APFloat::IEEEquad(), "0x1.ffffffffffffffffffffffffffffp-16382"); + expected = APFloat(APFloat::IEEEquad(), "0x1p-16381"); EXPECT_EQ(test.next(false), APFloat::opOK); EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextDown(0x1p-16381) -> 0x1.ffffffffffffffffffffffffffffp-16382 - test = APFloat(APFloat::IEEEquad, "0x1p-16381"); - expected = APFloat(APFloat::IEEEquad, + test = APFloat(APFloat::IEEEquad(), "0x1p-16381"); + expected = APFloat(APFloat::IEEEquad(), "0x1.ffffffffffffffffffffffffffffp-16382"); EXPECT_EQ(test.next(true), APFloat::opOK); EXPECT_TRUE(test.bitwiseIsEqual(expected)); @@ -373,9 +373,9 @@ // * nextDown(-Normal) -> -Normal. // nextUp(+Denormal) -> +Denormal. - test = APFloat(APFloat::IEEEquad, + test = APFloat(APFloat::IEEEquad(), "0x0.ffffffffffffffffffffffff000cp-16382"); - expected = APFloat(APFloat::IEEEquad, + expected = APFloat(APFloat::IEEEquad(), "0x0.ffffffffffffffffffffffff000dp-16382"); EXPECT_EQ(test.next(false), APFloat::opOK); EXPECT_TRUE(test.isDenormal()); @@ -383,9 +383,9 @@ EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextDown(+Denormal) -> +Denormal. - test = APFloat(APFloat::IEEEquad, + test = APFloat(APFloat::IEEEquad(), "0x0.ffffffffffffffffffffffff000cp-16382"); - expected = APFloat(APFloat::IEEEquad, + expected = APFloat(APFloat::IEEEquad(), "0x0.ffffffffffffffffffffffff000bp-16382"); EXPECT_EQ(test.next(true), APFloat::opOK); EXPECT_TRUE(test.isDenormal()); @@ -393,9 +393,9 @@ EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextUp(-Denormal) -> -Denormal. - test = APFloat(APFloat::IEEEquad, + test = APFloat(APFloat::IEEEquad(), "-0x0.ffffffffffffffffffffffff000cp-16382"); - expected = APFloat(APFloat::IEEEquad, + expected = APFloat(APFloat::IEEEquad(), "-0x0.ffffffffffffffffffffffff000bp-16382"); EXPECT_EQ(test.next(false), APFloat::opOK); EXPECT_TRUE(test.isDenormal()); @@ -403,9 +403,9 @@ EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextDown(-Denormal) -> -Denormal - test = APFloat(APFloat::IEEEquad, + test = APFloat(APFloat::IEEEquad(), "-0x0.ffffffffffffffffffffffff000cp-16382"); - expected = APFloat(APFloat::IEEEquad, + expected = APFloat(APFloat::IEEEquad(), "-0x0.ffffffffffffffffffffffff000dp-16382"); EXPECT_EQ(test.next(true), APFloat::opOK); EXPECT_TRUE(test.isDenormal()); @@ -413,9 +413,9 @@ EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextUp(+Normal) -> +Normal. - test = APFloat(APFloat::IEEEquad, + test = APFloat(APFloat::IEEEquad(), "0x1.ffffffffffffffffffffffff000cp-16000"); - expected = APFloat(APFloat::IEEEquad, + expected = APFloat(APFloat::IEEEquad(), "0x1.ffffffffffffffffffffffff000dp-16000"); EXPECT_EQ(test.next(false), APFloat::opOK); EXPECT_TRUE(!test.isDenormal()); @@ -423,9 +423,9 @@ EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextDown(+Normal) -> +Normal. - test = APFloat(APFloat::IEEEquad, + test = APFloat(APFloat::IEEEquad(), "0x1.ffffffffffffffffffffffff000cp-16000"); - expected = APFloat(APFloat::IEEEquad, + expected = APFloat(APFloat::IEEEquad(), "0x1.ffffffffffffffffffffffff000bp-16000"); EXPECT_EQ(test.next(true), APFloat::opOK); EXPECT_TRUE(!test.isDenormal()); @@ -433,9 +433,9 @@ EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextUp(-Normal) -> -Normal. - test = APFloat(APFloat::IEEEquad, + test = APFloat(APFloat::IEEEquad(), "-0x1.ffffffffffffffffffffffff000cp-16000"); - expected = APFloat(APFloat::IEEEquad, + expected = APFloat(APFloat::IEEEquad(), "-0x1.ffffffffffffffffffffffff000bp-16000"); EXPECT_EQ(test.next(false), APFloat::opOK); EXPECT_TRUE(!test.isDenormal()); @@ -443,9 +443,9 @@ EXPECT_TRUE(test.bitwiseIsEqual(expected)); // nextDown(-Normal) -> -Normal. - test = APFloat(APFloat::IEEEquad, + test = APFloat(APFloat::IEEEquad(), "-0x1.ffffffffffffffffffffffff000cp-16000"); - expected = APFloat(APFloat::IEEEquad, + expected = APFloat(APFloat::IEEEquad(), "-0x1.ffffffffffffffffffffffff000dp-16000"); EXPECT_EQ(test.next(true), APFloat::opOK); EXPECT_TRUE(!test.isDenormal()); @@ -508,8 +508,8 @@ // Test -ve sign preservation when small negative results underflow. { - APFloat f1(APFloat::IEEEdouble, "-0x1p-1074"); - APFloat f2(APFloat::IEEEdouble, "+0x1p-1074"); + APFloat f1(APFloat::IEEEdouble(), "-0x1p-1074"); + APFloat f2(APFloat::IEEEdouble(), "+0x1p-1074"); APFloat f3(0.0); f1.fusedMultiplyAdd(f2, f3, APFloat::rmNearestTiesToEven); EXPECT_TRUE(f1.isNegative() && f1.isZero()); @@ -517,13 +517,13 @@ // Test x87 extended precision case from http://llvm.org/PR20728. { - APFloat M1(APFloat::x87DoubleExtended, 1.0); - APFloat M2(APFloat::x87DoubleExtended, 1.0); - APFloat A(APFloat::x87DoubleExtended, 3.0); + APFloat M1(APFloat::x87DoubleExtended(), 1.0); + APFloat M2(APFloat::x87DoubleExtended(), 1.0); + APFloat A(APFloat::x87DoubleExtended(), 3.0); bool losesInfo = false; M1.fusedMultiplyAdd(M1, A, APFloat::rmNearestTiesToEven); - M1.convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven, &losesInfo); + M1.convert(APFloat::IEEEsingle(), APFloat::rmNearestTiesToEven, &losesInfo); EXPECT_FALSE(losesInfo); EXPECT_EQ(4.0f, M1.convertToFloat()); } @@ -532,7 +532,7 @@ TEST(APFloatTest, MinNum) { APFloat f1(1.0); APFloat f2(2.0); - APFloat nan = APFloat::getNaN(APFloat::IEEEdouble); + APFloat nan = APFloat::getNaN(APFloat::IEEEdouble()); EXPECT_EQ(1.0, minnum(f1, f2).convertToDouble()); EXPECT_EQ(1.0, minnum(f2, f1).convertToDouble()); @@ -543,7 +543,7 @@ TEST(APFloatTest, MaxNum) { APFloat f1(1.0); APFloat f2(2.0); - APFloat nan = APFloat::getNaN(APFloat::IEEEdouble); + APFloat nan = APFloat::getNaN(APFloat::IEEEdouble()); EXPECT_EQ(2.0, maxnum(f1, f2).convertToDouble()); EXPECT_EQ(2.0, maxnum(f2, f1).convertToDouble()); @@ -557,11 +557,11 @@ // Test single precision { const char *MinNormalStr = "1.17549435082228750797e-38"; - EXPECT_FALSE(APFloat(APFloat::IEEEsingle, MinNormalStr).isDenormal()); - EXPECT_FALSE(APFloat(APFloat::IEEEsingle, 0.0).isDenormal()); + EXPECT_FALSE(APFloat(APFloat::IEEEsingle(), MinNormalStr).isDenormal()); + EXPECT_FALSE(APFloat(APFloat::IEEEsingle(), 0.0).isDenormal()); - APFloat Val2(APFloat::IEEEsingle, 2.0e0); - APFloat T(APFloat::IEEEsingle, MinNormalStr); + APFloat Val2(APFloat::IEEEsingle(), 2.0e0); + APFloat T(APFloat::IEEEsingle(), MinNormalStr); T.divide(Val2, rdmd); EXPECT_TRUE(T.isDenormal()); } @@ -569,11 +569,11 @@ // Test double precision { const char *MinNormalStr = "2.22507385850720138309e-308"; - EXPECT_FALSE(APFloat(APFloat::IEEEdouble, MinNormalStr).isDenormal()); - EXPECT_FALSE(APFloat(APFloat::IEEEdouble, 0.0).isDenormal()); + EXPECT_FALSE(APFloat(APFloat::IEEEdouble(), MinNormalStr).isDenormal()); + EXPECT_FALSE(APFloat(APFloat::IEEEdouble(), 0.0).isDenormal()); - APFloat Val2(APFloat::IEEEdouble, 2.0e0); - APFloat T(APFloat::IEEEdouble, MinNormalStr); + APFloat Val2(APFloat::IEEEdouble(), 2.0e0); + APFloat T(APFloat::IEEEdouble(), MinNormalStr); T.divide(Val2, rdmd); EXPECT_TRUE(T.isDenormal()); } @@ -581,11 +581,11 @@ // Test Intel double-ext { const char *MinNormalStr = "3.36210314311209350626e-4932"; - EXPECT_FALSE(APFloat(APFloat::x87DoubleExtended, MinNormalStr).isDenormal()); - EXPECT_FALSE(APFloat(APFloat::x87DoubleExtended, 0.0).isDenormal()); + EXPECT_FALSE(APFloat(APFloat::x87DoubleExtended(), MinNormalStr).isDenormal()); + EXPECT_FALSE(APFloat(APFloat::x87DoubleExtended(), 0.0).isDenormal()); - APFloat Val2(APFloat::x87DoubleExtended, 2.0e0); - APFloat T(APFloat::x87DoubleExtended, MinNormalStr); + APFloat Val2(APFloat::x87DoubleExtended(), 2.0e0); + APFloat T(APFloat::x87DoubleExtended(), MinNormalStr); T.divide(Val2, rdmd); EXPECT_TRUE(T.isDenormal()); } @@ -593,11 +593,11 @@ // Test quadruple precision { const char *MinNormalStr = "3.36210314311209350626267781732175260e-4932"; - EXPECT_FALSE(APFloat(APFloat::IEEEquad, MinNormalStr).isDenormal()); - EXPECT_FALSE(APFloat(APFloat::IEEEquad, 0.0).isDenormal()); + EXPECT_FALSE(APFloat(APFloat::IEEEquad(), MinNormalStr).isDenormal()); + EXPECT_FALSE(APFloat(APFloat::IEEEquad(), 0.0).isDenormal()); - APFloat Val2(APFloat::IEEEquad, 2.0e0); - APFloat T(APFloat::IEEEquad, MinNormalStr); + APFloat Val2(APFloat::IEEEquad(), 2.0e0); + APFloat T(APFloat::IEEEquad(), MinNormalStr); T.divide(Val2, rdmd); EXPECT_TRUE(T.isDenormal()); } @@ -616,7 +616,7 @@ TEST(APFloatTest, DecimalStringsWithoutNullTerminators) { // Make sure that we can parse strings without null terminators. // rdar://14323230. - APFloat Val(APFloat::IEEEdouble); + APFloat Val(APFloat::IEEEdouble()); Val.convertFromString(StringRef("0.00", 3), llvm::APFloat::rmNearestTiesToEven); EXPECT_EQ(Val.convertToDouble(), 0.0); @@ -639,292 +639,292 @@ } TEST(APFloatTest, fromZeroDecimalString) { - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0.").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0.").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0.").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0.").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0.").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0.").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, ".0").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+.0").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-.0").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), ".0").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+.0").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-.0").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0.0").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0.0").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0.0").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0.0").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0.0").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0.0").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "00000.").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+00000.").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-00000.").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "00000.").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+00000.").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-00000.").convertToDouble()); - EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, ".00000").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+.00000").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-.00000").convertToDouble()); + EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble(), ".00000").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+.00000").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-.00000").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0000.00000").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0000.00000").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0000.00000").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0000.00000").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0000.00000").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0000.00000").convertToDouble()); } TEST(APFloatTest, fromZeroDecimalSingleExponentString) { - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0e1").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0e1").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0e1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0e1").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0e1").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0e1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0e+1").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0e+1").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0e+1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0e+1").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0e+1").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0e+1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0e-1").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0e-1").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0e-1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0e-1").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0e-1").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0e-1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0.e1").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0.e1").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0.e1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0.e1").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0.e1").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0.e1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0.e+1").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0.e+1").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0.e+1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0.e+1").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0.e+1").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0.e+1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0.e-1").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0.e-1").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0.e-1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0.e-1").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0.e-1").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0.e-1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, ".0e1").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+.0e1").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-.0e1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), ".0e1").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+.0e1").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-.0e1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, ".0e+1").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+.0e+1").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-.0e+1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), ".0e+1").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+.0e+1").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-.0e+1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, ".0e-1").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+.0e-1").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-.0e-1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), ".0e-1").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+.0e-1").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-.0e-1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0.0e1").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0.0e1").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0.0e1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0.0e1").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0.0e1").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0.0e1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0.0e+1").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0.0e+1").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0.0e+1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0.0e+1").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0.0e+1").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0.0e+1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0.0e-1").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0.0e-1").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0.0e-1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0.0e-1").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0.0e-1").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0.0e-1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "000.0000e1").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+000.0000e+1").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-000.0000e+1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "000.0000e1").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+000.0000e+1").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-000.0000e+1").convertToDouble()); } TEST(APFloatTest, fromZeroDecimalLargeExponentString) { - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0e1234").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0e1234").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0e1234").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0e1234").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0e1234").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0e1234").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0e+1234").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0e+1234").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0e+1234").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0e+1234").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0e+1234").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0e+1234").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0e-1234").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0e-1234").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0e-1234").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0e-1234").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0e-1234").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0e-1234").convertToDouble()); - EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "000.0000e1234").convertToDouble()); - EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "000.0000e-1234").convertToDouble()); + EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble(), "000.0000e1234").convertToDouble()); + EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble(), "000.0000e-1234").convertToDouble()); - EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, StringRef("0e1234\02", 6)).convertToDouble()); + EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble(), StringRef("0e1234\02", 6)).convertToDouble()); } TEST(APFloatTest, fromZeroHexadecimalString) { - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0p1").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0x0p1").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x0p1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0x0p1").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0x0p1").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0x0p1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0p+1").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0x0p+1").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x0p+1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0x0p+1").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0x0p+1").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0x0p+1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0p-1").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0x0p-1").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x0p-1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0x0p-1").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0x0p-1").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0x0p-1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0.p1").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0x0.p1").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x0.p1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0x0.p1").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0x0.p1").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0x0.p1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0.p+1").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0x0.p+1").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x0.p+1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0x0.p+1").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0x0.p+1").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0x0.p+1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0.p-1").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0x0.p-1").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x0.p-1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0x0.p-1").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0x0.p-1").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0x0.p-1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x.0p1").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0x.0p1").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x.0p1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0x.0p1").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0x.0p1").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0x.0p1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x.0p+1").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0x.0p+1").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x.0p+1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0x.0p+1").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0x.0p+1").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0x.0p+1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x.0p-1").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0x.0p-1").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x.0p-1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0x.0p-1").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0x.0p-1").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0x.0p-1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0.0p1").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0x0.0p1").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x0.0p1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0x0.0p1").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0x0.0p1").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0x0.0p1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0.0p+1").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0x0.0p+1").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x0.0p+1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0x0.0p+1").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0x0.0p+1").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0x0.0p+1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0.0p-1").convertToDouble()); - EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble, "+0x0.0p-1").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x0.0p-1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0x0.0p-1").convertToDouble()); + EXPECT_EQ(+0.0, APFloat(APFloat::IEEEdouble(), "+0x0.0p-1").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0x0.0p-1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x00000.p1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0000.00000p1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x.00000p1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0.p1").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0p1234").convertToDouble()); - EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x0p1234").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x00000.p1234").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0000.00000p1234").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x.00000p1234").convertToDouble()); - EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble, "0x0.p1234").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0x00000.p1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0x0000.00000p1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0x.00000p1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0x0.p1").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0x0p1234").convertToDouble()); + EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble(), "-0x0p1234").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0x00000.p1234").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0x0000.00000p1234").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0x.00000p1234").convertToDouble()); + EXPECT_EQ( 0.0, APFloat(APFloat::IEEEdouble(), "0x0.p1234").convertToDouble()); } TEST(APFloatTest, fromDecimalString) { - EXPECT_EQ(1.0, APFloat(APFloat::IEEEdouble, "1").convertToDouble()); - EXPECT_EQ(2.0, APFloat(APFloat::IEEEdouble, "2.").convertToDouble()); - EXPECT_EQ(0.5, APFloat(APFloat::IEEEdouble, ".5").convertToDouble()); - EXPECT_EQ(1.0, APFloat(APFloat::IEEEdouble, "1.0").convertToDouble()); - EXPECT_EQ(-2.0, APFloat(APFloat::IEEEdouble, "-2").convertToDouble()); - EXPECT_EQ(-4.0, APFloat(APFloat::IEEEdouble, "-4.").convertToDouble()); - EXPECT_EQ(-0.5, APFloat(APFloat::IEEEdouble, "-.5").convertToDouble()); - EXPECT_EQ(-1.5, APFloat(APFloat::IEEEdouble, "-1.5").convertToDouble()); - EXPECT_EQ(1.25e12, APFloat(APFloat::IEEEdouble, "1.25e12").convertToDouble()); - EXPECT_EQ(1.25e+12, APFloat(APFloat::IEEEdouble, "1.25e+12").convertToDouble()); - EXPECT_EQ(1.25e-12, APFloat(APFloat::IEEEdouble, "1.25e-12").convertToDouble()); - EXPECT_EQ(1024.0, APFloat(APFloat::IEEEdouble, "1024.").convertToDouble()); - EXPECT_EQ(1024.05, APFloat(APFloat::IEEEdouble, "1024.05000").convertToDouble()); - EXPECT_EQ(0.05, APFloat(APFloat::IEEEdouble, ".05000").convertToDouble()); - EXPECT_EQ(2.0, APFloat(APFloat::IEEEdouble, "2.").convertToDouble()); - EXPECT_EQ(2.0e2, APFloat(APFloat::IEEEdouble, "2.e2").convertToDouble()); - EXPECT_EQ(2.0e+2, APFloat(APFloat::IEEEdouble, "2.e+2").convertToDouble()); - EXPECT_EQ(2.0e-2, APFloat(APFloat::IEEEdouble, "2.e-2").convertToDouble()); - EXPECT_EQ(2.05e2, APFloat(APFloat::IEEEdouble, "002.05000e2").convertToDouble()); - EXPECT_EQ(2.05e+2, APFloat(APFloat::IEEEdouble, "002.05000e+2").convertToDouble()); - EXPECT_EQ(2.05e-2, APFloat(APFloat::IEEEdouble, "002.05000e-2").convertToDouble()); - EXPECT_EQ(2.05e12, APFloat(APFloat::IEEEdouble, "002.05000e12").convertToDouble()); - EXPECT_EQ(2.05e+12, APFloat(APFloat::IEEEdouble, "002.05000e+12").convertToDouble()); - EXPECT_EQ(2.05e-12, APFloat(APFloat::IEEEdouble, "002.05000e-12").convertToDouble()); + EXPECT_EQ(1.0, APFloat(APFloat::IEEEdouble(), "1").convertToDouble()); + EXPECT_EQ(2.0, APFloat(APFloat::IEEEdouble(), "2.").convertToDouble()); + EXPECT_EQ(0.5, APFloat(APFloat::IEEEdouble(), ".5").convertToDouble()); + EXPECT_EQ(1.0, APFloat(APFloat::IEEEdouble(), "1.0").convertToDouble()); + EXPECT_EQ(-2.0, APFloat(APFloat::IEEEdouble(), "-2").convertToDouble()); + EXPECT_EQ(-4.0, APFloat(APFloat::IEEEdouble(), "-4.").convertToDouble()); + EXPECT_EQ(-0.5, APFloat(APFloat::IEEEdouble(), "-.5").convertToDouble()); + EXPECT_EQ(-1.5, APFloat(APFloat::IEEEdouble(), "-1.5").convertToDouble()); + EXPECT_EQ(1.25e12, APFloat(APFloat::IEEEdouble(), "1.25e12").convertToDouble()); + EXPECT_EQ(1.25e+12, APFloat(APFloat::IEEEdouble(), "1.25e+12").convertToDouble()); + EXPECT_EQ(1.25e-12, APFloat(APFloat::IEEEdouble(), "1.25e-12").convertToDouble()); + EXPECT_EQ(1024.0, APFloat(APFloat::IEEEdouble(), "1024.").convertToDouble()); + EXPECT_EQ(1024.05, APFloat(APFloat::IEEEdouble(), "1024.05000").convertToDouble()); + EXPECT_EQ(0.05, APFloat(APFloat::IEEEdouble(), ".05000").convertToDouble()); + EXPECT_EQ(2.0, APFloat(APFloat::IEEEdouble(), "2.").convertToDouble()); + EXPECT_EQ(2.0e2, APFloat(APFloat::IEEEdouble(), "2.e2").convertToDouble()); + EXPECT_EQ(2.0e+2, APFloat(APFloat::IEEEdouble(), "2.e+2").convertToDouble()); + EXPECT_EQ(2.0e-2, APFloat(APFloat::IEEEdouble(), "2.e-2").convertToDouble()); + EXPECT_EQ(2.05e2, APFloat(APFloat::IEEEdouble(), "002.05000e2").convertToDouble()); + EXPECT_EQ(2.05e+2, APFloat(APFloat::IEEEdouble(), "002.05000e+2").convertToDouble()); + EXPECT_EQ(2.05e-2, APFloat(APFloat::IEEEdouble(), "002.05000e-2").convertToDouble()); + EXPECT_EQ(2.05e12, APFloat(APFloat::IEEEdouble(), "002.05000e12").convertToDouble()); + EXPECT_EQ(2.05e+12, APFloat(APFloat::IEEEdouble(), "002.05000e+12").convertToDouble()); + EXPECT_EQ(2.05e-12, APFloat(APFloat::IEEEdouble(), "002.05000e-12").convertToDouble()); // These are "carefully selected" to overflow the fast log-base // calculations in APFloat.cpp - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "99e99999").isInfinity()); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "-99e99999").isInfinity()); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "1e-99999").isPosZero()); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "-1e-99999").isNegZero()); + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "99e99999").isInfinity()); + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "-99e99999").isInfinity()); + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "1e-99999").isPosZero()); + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "-1e-99999").isNegZero()); EXPECT_EQ(2.71828, convertToDoubleFromString("2.71828")); } TEST(APFloatTest, fromHexadecimalString) { - EXPECT_EQ( 1.0, APFloat(APFloat::IEEEdouble, "0x1p0").convertToDouble()); - EXPECT_EQ(+1.0, APFloat(APFloat::IEEEdouble, "+0x1p0").convertToDouble()); - EXPECT_EQ(-1.0, APFloat(APFloat::IEEEdouble, "-0x1p0").convertToDouble()); + EXPECT_EQ( 1.0, APFloat(APFloat::IEEEdouble(), "0x1p0").convertToDouble()); + EXPECT_EQ(+1.0, APFloat(APFloat::IEEEdouble(), "+0x1p0").convertToDouble()); + EXPECT_EQ(-1.0, APFloat(APFloat::IEEEdouble(), "-0x1p0").convertToDouble()); - EXPECT_EQ( 1.0, APFloat(APFloat::IEEEdouble, "0x1p+0").convertToDouble()); - EXPECT_EQ(+1.0, APFloat(APFloat::IEEEdouble, "+0x1p+0").convertToDouble()); - EXPECT_EQ(-1.0, APFloat(APFloat::IEEEdouble, "-0x1p+0").convertToDouble()); + EXPECT_EQ( 1.0, APFloat(APFloat::IEEEdouble(), "0x1p+0").convertToDouble()); + EXPECT_EQ(+1.0, APFloat(APFloat::IEEEdouble(), "+0x1p+0").convertToDouble()); + EXPECT_EQ(-1.0, APFloat(APFloat::IEEEdouble(), "-0x1p+0").convertToDouble()); - EXPECT_EQ( 1.0, APFloat(APFloat::IEEEdouble, "0x1p-0").convertToDouble()); - EXPECT_EQ(+1.0, APFloat(APFloat::IEEEdouble, "+0x1p-0").convertToDouble()); - EXPECT_EQ(-1.0, APFloat(APFloat::IEEEdouble, "-0x1p-0").convertToDouble()); + EXPECT_EQ( 1.0, APFloat(APFloat::IEEEdouble(), "0x1p-0").convertToDouble()); + EXPECT_EQ(+1.0, APFloat(APFloat::IEEEdouble(), "+0x1p-0").convertToDouble()); + EXPECT_EQ(-1.0, APFloat(APFloat::IEEEdouble(), "-0x1p-0").convertToDouble()); - EXPECT_EQ( 2.0, APFloat(APFloat::IEEEdouble, "0x1p1").convertToDouble()); - EXPECT_EQ(+2.0, APFloat(APFloat::IEEEdouble, "+0x1p1").convertToDouble()); - EXPECT_EQ(-2.0, APFloat(APFloat::IEEEdouble, "-0x1p1").convertToDouble()); + EXPECT_EQ( 2.0, APFloat(APFloat::IEEEdouble(), "0x1p1").convertToDouble()); + EXPECT_EQ(+2.0, APFloat(APFloat::IEEEdouble(), "+0x1p1").convertToDouble()); + EXPECT_EQ(-2.0, APFloat(APFloat::IEEEdouble(), "-0x1p1").convertToDouble()); - EXPECT_EQ( 2.0, APFloat(APFloat::IEEEdouble, "0x1p+1").convertToDouble()); - EXPECT_EQ(+2.0, APFloat(APFloat::IEEEdouble, "+0x1p+1").convertToDouble()); - EXPECT_EQ(-2.0, APFloat(APFloat::IEEEdouble, "-0x1p+1").convertToDouble()); + EXPECT_EQ( 2.0, APFloat(APFloat::IEEEdouble(), "0x1p+1").convertToDouble()); + EXPECT_EQ(+2.0, APFloat(APFloat::IEEEdouble(), "+0x1p+1").convertToDouble()); + EXPECT_EQ(-2.0, APFloat(APFloat::IEEEdouble(), "-0x1p+1").convertToDouble()); - EXPECT_EQ( 0.5, APFloat(APFloat::IEEEdouble, "0x1p-1").convertToDouble()); - EXPECT_EQ(+0.5, APFloat(APFloat::IEEEdouble, "+0x1p-1").convertToDouble()); - EXPECT_EQ(-0.5, APFloat(APFloat::IEEEdouble, "-0x1p-1").convertToDouble()); + EXPECT_EQ( 0.5, APFloat(APFloat::IEEEdouble(), "0x1p-1").convertToDouble()); + EXPECT_EQ(+0.5, APFloat(APFloat::IEEEdouble(), "+0x1p-1").convertToDouble()); + EXPECT_EQ(-0.5, APFloat(APFloat::IEEEdouble(), "-0x1p-1").convertToDouble()); - EXPECT_EQ( 3.0, APFloat(APFloat::IEEEdouble, "0x1.8p1").convertToDouble()); - EXPECT_EQ(+3.0, APFloat(APFloat::IEEEdouble, "+0x1.8p1").convertToDouble()); - EXPECT_EQ(-3.0, APFloat(APFloat::IEEEdouble, "-0x1.8p1").convertToDouble()); + EXPECT_EQ( 3.0, APFloat(APFloat::IEEEdouble(), "0x1.8p1").convertToDouble()); + EXPECT_EQ(+3.0, APFloat(APFloat::IEEEdouble(), "+0x1.8p1").convertToDouble()); + EXPECT_EQ(-3.0, APFloat(APFloat::IEEEdouble(), "-0x1.8p1").convertToDouble()); - EXPECT_EQ( 3.0, APFloat(APFloat::IEEEdouble, "0x1.8p+1").convertToDouble()); - EXPECT_EQ(+3.0, APFloat(APFloat::IEEEdouble, "+0x1.8p+1").convertToDouble()); - EXPECT_EQ(-3.0, APFloat(APFloat::IEEEdouble, "-0x1.8p+1").convertToDouble()); + EXPECT_EQ( 3.0, APFloat(APFloat::IEEEdouble(), "0x1.8p+1").convertToDouble()); + EXPECT_EQ(+3.0, APFloat(APFloat::IEEEdouble(), "+0x1.8p+1").convertToDouble()); + EXPECT_EQ(-3.0, APFloat(APFloat::IEEEdouble(), "-0x1.8p+1").convertToDouble()); - EXPECT_EQ( 0.75, APFloat(APFloat::IEEEdouble, "0x1.8p-1").convertToDouble()); - EXPECT_EQ(+0.75, APFloat(APFloat::IEEEdouble, "+0x1.8p-1").convertToDouble()); - EXPECT_EQ(-0.75, APFloat(APFloat::IEEEdouble, "-0x1.8p-1").convertToDouble()); + EXPECT_EQ( 0.75, APFloat(APFloat::IEEEdouble(), "0x1.8p-1").convertToDouble()); + EXPECT_EQ(+0.75, APFloat(APFloat::IEEEdouble(), "+0x1.8p-1").convertToDouble()); + EXPECT_EQ(-0.75, APFloat(APFloat::IEEEdouble(), "-0x1.8p-1").convertToDouble()); - EXPECT_EQ( 8192.0, APFloat(APFloat::IEEEdouble, "0x1000.000p1").convertToDouble()); - EXPECT_EQ(+8192.0, APFloat(APFloat::IEEEdouble, "+0x1000.000p1").convertToDouble()); - EXPECT_EQ(-8192.0, APFloat(APFloat::IEEEdouble, "-0x1000.000p1").convertToDouble()); + EXPECT_EQ( 8192.0, APFloat(APFloat::IEEEdouble(), "0x1000.000p1").convertToDouble()); + EXPECT_EQ(+8192.0, APFloat(APFloat::IEEEdouble(), "+0x1000.000p1").convertToDouble()); + EXPECT_EQ(-8192.0, APFloat(APFloat::IEEEdouble(), "-0x1000.000p1").convertToDouble()); - EXPECT_EQ( 8192.0, APFloat(APFloat::IEEEdouble, "0x1000.000p+1").convertToDouble()); - EXPECT_EQ(+8192.0, APFloat(APFloat::IEEEdouble, "+0x1000.000p+1").convertToDouble()); - EXPECT_EQ(-8192.0, APFloat(APFloat::IEEEdouble, "-0x1000.000p+1").convertToDouble()); + EXPECT_EQ( 8192.0, APFloat(APFloat::IEEEdouble(), "0x1000.000p+1").convertToDouble()); + EXPECT_EQ(+8192.0, APFloat(APFloat::IEEEdouble(), "+0x1000.000p+1").convertToDouble()); + EXPECT_EQ(-8192.0, APFloat(APFloat::IEEEdouble(), "-0x1000.000p+1").convertToDouble()); - EXPECT_EQ( 2048.0, APFloat(APFloat::IEEEdouble, "0x1000.000p-1").convertToDouble()); - EXPECT_EQ(+2048.0, APFloat(APFloat::IEEEdouble, "+0x1000.000p-1").convertToDouble()); - EXPECT_EQ(-2048.0, APFloat(APFloat::IEEEdouble, "-0x1000.000p-1").convertToDouble()); + EXPECT_EQ( 2048.0, APFloat(APFloat::IEEEdouble(), "0x1000.000p-1").convertToDouble()); + EXPECT_EQ(+2048.0, APFloat(APFloat::IEEEdouble(), "+0x1000.000p-1").convertToDouble()); + EXPECT_EQ(-2048.0, APFloat(APFloat::IEEEdouble(), "-0x1000.000p-1").convertToDouble()); - EXPECT_EQ( 8192.0, APFloat(APFloat::IEEEdouble, "0x1000p1").convertToDouble()); - EXPECT_EQ(+8192.0, APFloat(APFloat::IEEEdouble, "+0x1000p1").convertToDouble()); - EXPECT_EQ(-8192.0, APFloat(APFloat::IEEEdouble, "-0x1000p1").convertToDouble()); + EXPECT_EQ( 8192.0, APFloat(APFloat::IEEEdouble(), "0x1000p1").convertToDouble()); + EXPECT_EQ(+8192.0, APFloat(APFloat::IEEEdouble(), "+0x1000p1").convertToDouble()); + EXPECT_EQ(-8192.0, APFloat(APFloat::IEEEdouble(), "-0x1000p1").convertToDouble()); - EXPECT_EQ( 8192.0, APFloat(APFloat::IEEEdouble, "0x1000p+1").convertToDouble()); - EXPECT_EQ(+8192.0, APFloat(APFloat::IEEEdouble, "+0x1000p+1").convertToDouble()); - EXPECT_EQ(-8192.0, APFloat(APFloat::IEEEdouble, "-0x1000p+1").convertToDouble()); + EXPECT_EQ( 8192.0, APFloat(APFloat::IEEEdouble(), "0x1000p+1").convertToDouble()); + EXPECT_EQ(+8192.0, APFloat(APFloat::IEEEdouble(), "+0x1000p+1").convertToDouble()); + EXPECT_EQ(-8192.0, APFloat(APFloat::IEEEdouble(), "-0x1000p+1").convertToDouble()); - EXPECT_EQ( 2048.0, APFloat(APFloat::IEEEdouble, "0x1000p-1").convertToDouble()); - EXPECT_EQ(+2048.0, APFloat(APFloat::IEEEdouble, "+0x1000p-1").convertToDouble()); - EXPECT_EQ(-2048.0, APFloat(APFloat::IEEEdouble, "-0x1000p-1").convertToDouble()); + EXPECT_EQ( 2048.0, APFloat(APFloat::IEEEdouble(), "0x1000p-1").convertToDouble()); + EXPECT_EQ(+2048.0, APFloat(APFloat::IEEEdouble(), "+0x1000p-1").convertToDouble()); + EXPECT_EQ(-2048.0, APFloat(APFloat::IEEEdouble(), "-0x1000p-1").convertToDouble()); - EXPECT_EQ( 16384.0, APFloat(APFloat::IEEEdouble, "0x10p10").convertToDouble()); - EXPECT_EQ(+16384.0, APFloat(APFloat::IEEEdouble, "+0x10p10").convertToDouble()); - EXPECT_EQ(-16384.0, APFloat(APFloat::IEEEdouble, "-0x10p10").convertToDouble()); + EXPECT_EQ( 16384.0, APFloat(APFloat::IEEEdouble(), "0x10p10").convertToDouble()); + EXPECT_EQ(+16384.0, APFloat(APFloat::IEEEdouble(), "+0x10p10").convertToDouble()); + EXPECT_EQ(-16384.0, APFloat(APFloat::IEEEdouble(), "-0x10p10").convertToDouble()); - EXPECT_EQ( 16384.0, APFloat(APFloat::IEEEdouble, "0x10p+10").convertToDouble()); - EXPECT_EQ(+16384.0, APFloat(APFloat::IEEEdouble, "+0x10p+10").convertToDouble()); - EXPECT_EQ(-16384.0, APFloat(APFloat::IEEEdouble, "-0x10p+10").convertToDouble()); + EXPECT_EQ( 16384.0, APFloat(APFloat::IEEEdouble(), "0x10p+10").convertToDouble()); + EXPECT_EQ(+16384.0, APFloat(APFloat::IEEEdouble(), "+0x10p+10").convertToDouble()); + EXPECT_EQ(-16384.0, APFloat(APFloat::IEEEdouble(), "-0x10p+10").convertToDouble()); - EXPECT_EQ( 0.015625, APFloat(APFloat::IEEEdouble, "0x10p-10").convertToDouble()); - EXPECT_EQ(+0.015625, APFloat(APFloat::IEEEdouble, "+0x10p-10").convertToDouble()); - EXPECT_EQ(-0.015625, APFloat(APFloat::IEEEdouble, "-0x10p-10").convertToDouble()); + EXPECT_EQ( 0.015625, APFloat(APFloat::IEEEdouble(), "0x10p-10").convertToDouble()); + EXPECT_EQ(+0.015625, APFloat(APFloat::IEEEdouble(), "+0x10p-10").convertToDouble()); + EXPECT_EQ(-0.015625, APFloat(APFloat::IEEEdouble(), "-0x10p-10").convertToDouble()); - EXPECT_EQ(1.0625, APFloat(APFloat::IEEEdouble, "0x1.1p0").convertToDouble()); - EXPECT_EQ(1.0, APFloat(APFloat::IEEEdouble, "0x1p0").convertToDouble()); + EXPECT_EQ(1.0625, APFloat(APFloat::IEEEdouble(), "0x1.1p0").convertToDouble()); + EXPECT_EQ(1.0, APFloat(APFloat::IEEEdouble(), "0x1p0").convertToDouble()); EXPECT_EQ(convertToDoubleFromString("0x1p-150"), convertToDoubleFromString("+0x800000000000000001.p-221")); @@ -953,44 +953,44 @@ APSInt result(5, /*isUnsigned=*/true); EXPECT_EQ(APFloat::opOK, - APFloat(APFloat::IEEEdouble, "10") + APFloat(APFloat::IEEEdouble(), "10") .convertToInteger(result, APFloat::rmTowardZero, &isExact)); EXPECT_TRUE(isExact); EXPECT_EQ(APSInt(APInt(5, 10), true), result); EXPECT_EQ(APFloat::opInvalidOp, - APFloat(APFloat::IEEEdouble, "-10") + APFloat(APFloat::IEEEdouble(), "-10") .convertToInteger(result, APFloat::rmTowardZero, &isExact)); EXPECT_FALSE(isExact); EXPECT_EQ(APSInt::getMinValue(5, true), result); EXPECT_EQ(APFloat::opInvalidOp, - APFloat(APFloat::IEEEdouble, "32") + APFloat(APFloat::IEEEdouble(), "32") .convertToInteger(result, APFloat::rmTowardZero, &isExact)); EXPECT_FALSE(isExact); EXPECT_EQ(APSInt::getMaxValue(5, true), result); EXPECT_EQ(APFloat::opInexact, - APFloat(APFloat::IEEEdouble, "7.9") + APFloat(APFloat::IEEEdouble(), "7.9") .convertToInteger(result, APFloat::rmTowardZero, &isExact)); EXPECT_FALSE(isExact); EXPECT_EQ(APSInt(APInt(5, 7), true), result); result.setIsUnsigned(false); EXPECT_EQ(APFloat::opOK, - APFloat(APFloat::IEEEdouble, "-10") + APFloat(APFloat::IEEEdouble(), "-10") .convertToInteger(result, APFloat::rmTowardZero, &isExact)); EXPECT_TRUE(isExact); EXPECT_EQ(APSInt(APInt(5, -10, true), false), result); EXPECT_EQ(APFloat::opInvalidOp, - APFloat(APFloat::IEEEdouble, "-17") + APFloat(APFloat::IEEEdouble(), "-17") .convertToInteger(result, APFloat::rmTowardZero, &isExact)); EXPECT_FALSE(isExact); EXPECT_EQ(APSInt::getMinValue(5, false), result); EXPECT_EQ(APFloat::opInvalidOp, - APFloat(APFloat::IEEEdouble, "16") + APFloat(APFloat::IEEEdouble(), "16") .convertToInteger(result, APFloat::rmTowardZero, &isExact)); EXPECT_FALSE(isExact); EXPECT_EQ(APSInt::getMaxValue(5, false), result); @@ -1006,224 +1006,224 @@ } TEST(APFloatTest, makeNaN) { - ASSERT_EQ(0x7fc00000, nanbits(APFloat::IEEEsingle, false, false, 0)); - ASSERT_EQ(0xffc00000, nanbits(APFloat::IEEEsingle, false, true, 0)); - ASSERT_EQ(0x7fc0ae72, nanbits(APFloat::IEEEsingle, false, false, 0xae72)); - ASSERT_EQ(0x7fffae72, nanbits(APFloat::IEEEsingle, false, false, 0xffffae72)); - ASSERT_EQ(0x7fa00000, nanbits(APFloat::IEEEsingle, true, false, 0)); - ASSERT_EQ(0xffa00000, nanbits(APFloat::IEEEsingle, true, true, 0)); - ASSERT_EQ(0x7f80ae72, nanbits(APFloat::IEEEsingle, true, false, 0xae72)); - ASSERT_EQ(0x7fbfae72, nanbits(APFloat::IEEEsingle, true, false, 0xffffae72)); - - ASSERT_EQ(0x7ff8000000000000ULL, nanbits(APFloat::IEEEdouble, false, false, 0)); - ASSERT_EQ(0xfff8000000000000ULL, nanbits(APFloat::IEEEdouble, false, true, 0)); - ASSERT_EQ(0x7ff800000000ae72ULL, nanbits(APFloat::IEEEdouble, false, false, 0xae72)); - ASSERT_EQ(0x7fffffffffffae72ULL, nanbits(APFloat::IEEEdouble, false, false, 0xffffffffffffae72ULL)); - ASSERT_EQ(0x7ff4000000000000ULL, nanbits(APFloat::IEEEdouble, true, false, 0)); - ASSERT_EQ(0xfff4000000000000ULL, nanbits(APFloat::IEEEdouble, true, true, 0)); - ASSERT_EQ(0x7ff000000000ae72ULL, nanbits(APFloat::IEEEdouble, true, false, 0xae72)); - ASSERT_EQ(0x7ff7ffffffffae72ULL, nanbits(APFloat::IEEEdouble, true, false, 0xffffffffffffae72ULL)); + ASSERT_EQ(0x7fc00000, nanbits(APFloat::IEEEsingle(), false, false, 0)); + ASSERT_EQ(0xffc00000, nanbits(APFloat::IEEEsingle(), false, true, 0)); + ASSERT_EQ(0x7fc0ae72, nanbits(APFloat::IEEEsingle(), false, false, 0xae72)); + ASSERT_EQ(0x7fffae72, nanbits(APFloat::IEEEsingle(), false, false, 0xffffae72)); + ASSERT_EQ(0x7fa00000, nanbits(APFloat::IEEEsingle(), true, false, 0)); + ASSERT_EQ(0xffa00000, nanbits(APFloat::IEEEsingle(), true, true, 0)); + ASSERT_EQ(0x7f80ae72, nanbits(APFloat::IEEEsingle(), true, false, 0xae72)); + ASSERT_EQ(0x7fbfae72, nanbits(APFloat::IEEEsingle(), true, false, 0xffffae72)); + + ASSERT_EQ(0x7ff8000000000000ULL, nanbits(APFloat::IEEEdouble(), false, false, 0)); + ASSERT_EQ(0xfff8000000000000ULL, nanbits(APFloat::IEEEdouble(), false, true, 0)); + ASSERT_EQ(0x7ff800000000ae72ULL, nanbits(APFloat::IEEEdouble(), false, false, 0xae72)); + ASSERT_EQ(0x7fffffffffffae72ULL, nanbits(APFloat::IEEEdouble(), false, false, 0xffffffffffffae72ULL)); + ASSERT_EQ(0x7ff4000000000000ULL, nanbits(APFloat::IEEEdouble(), true, false, 0)); + ASSERT_EQ(0xfff4000000000000ULL, nanbits(APFloat::IEEEdouble(), true, true, 0)); + ASSERT_EQ(0x7ff000000000ae72ULL, nanbits(APFloat::IEEEdouble(), true, false, 0xae72)); + ASSERT_EQ(0x7ff7ffffffffae72ULL, nanbits(APFloat::IEEEdouble(), true, false, 0xffffffffffffae72ULL)); } #ifdef GTEST_HAS_DEATH_TEST #ifndef NDEBUG TEST(APFloatTest, SemanticsDeath) { - EXPECT_DEATH(APFloat(APFloat::IEEEsingle, 0.0f).convertToDouble(), "Float semantics are not IEEEdouble"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, 0.0 ).convertToFloat(), "Float semantics are not IEEEsingle"); + EXPECT_DEATH(APFloat(APFloat::IEEEsingle(), 0.0f).convertToDouble(), "Float semantics are not IEEEdouble"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), 0.0 ).convertToFloat(), "Float semantics are not IEEEsingle"); } TEST(APFloatTest, StringDecimalDeath) { - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, ""), "Invalid string length"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+"), "String has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-"), "String has no digits"); - - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("\0", 1)), "Invalid character in significand"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("1\0", 2)), "Invalid character in significand"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("1\02", 3)), "Invalid character in significand"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("1\02e1", 5)), "Invalid character in significand"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("1e\0", 3)), "Invalid character in exponent"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("1e1\0", 4)), "Invalid character in exponent"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("1e1\02", 5)), "Invalid character in exponent"); - - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "1.0f"), "Invalid character in significand"); - - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, ".."), "String contains multiple dots"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "..0"), "String contains multiple dots"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "1.0.0"), "String contains multiple dots"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), ""), "Invalid string length"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+"), "String has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-"), "String has no digits"); + + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), StringRef("\0", 1)), "Invalid character in significand"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), StringRef("1\0", 2)), "Invalid character in significand"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), StringRef("1\02", 3)), "Invalid character in significand"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), StringRef("1\02e1", 5)), "Invalid character in significand"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), StringRef("1e\0", 3)), "Invalid character in exponent"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), StringRef("1e1\0", 4)), "Invalid character in exponent"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), StringRef("1e1\02", 5)), "Invalid character in exponent"); + + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "1.0f"), "Invalid character in significand"); + + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), ".."), "String contains multiple dots"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "..0"), "String contains multiple dots"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "1.0.0"), "String contains multiple dots"); } TEST(APFloatTest, StringDecimalSignificandDeath) { - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "."), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+."), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-."), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "."), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+."), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-."), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "e"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+e"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-e"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "e"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+e"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-e"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "e1"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+e1"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-e1"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "e1"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+e1"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-e1"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, ".e1"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+.e1"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-.e1"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), ".e1"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+.e1"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-.e1"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, ".e"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+.e"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-.e"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), ".e"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+.e"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-.e"), "Significand has no digits"); } TEST(APFloatTest, StringDecimalExponentDeath) { - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "1e"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+1e"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-1e"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "1e"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+1e"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-1e"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "1.e"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+1.e"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-1.e"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "1.e"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+1.e"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-1.e"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, ".1e"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+.1e"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-.1e"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), ".1e"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+.1e"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-.1e"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "1.1e"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+1.1e"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-1.1e"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "1.1e"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+1.1e"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-1.1e"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "1e+"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "1e-"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "1e+"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "1e-"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, ".1e"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, ".1e+"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, ".1e-"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), ".1e"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), ".1e+"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), ".1e-"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "1.0e"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "1.0e+"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "1.0e-"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "1.0e"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "1.0e+"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "1.0e-"), "Exponent has no digits"); } TEST(APFloatTest, StringHexadecimalDeath) { - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x"), "Invalid string"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x"), "Invalid string"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x"), "Invalid string"); - - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x0"), "Hex strings require an exponent"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x0"), "Hex strings require an exponent"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x0"), "Hex strings require an exponent"); - - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x0."), "Hex strings require an exponent"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x0."), "Hex strings require an exponent"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x0."), "Hex strings require an exponent"); - - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x.0"), "Hex strings require an exponent"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x.0"), "Hex strings require an exponent"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x.0"), "Hex strings require an exponent"); - - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x0.0"), "Hex strings require an exponent"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x0.0"), "Hex strings require an exponent"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x0.0"), "Hex strings require an exponent"); - - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x\0", 3)), "Invalid character in significand"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x1\0", 4)), "Invalid character in significand"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x1\02", 5)), "Invalid character in significand"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x1\02p1", 7)), "Invalid character in significand"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x1p\0", 5)), "Invalid character in exponent"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x1p1\0", 6)), "Invalid character in exponent"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x1p1\02", 7)), "Invalid character in exponent"); - - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x1p0f"), "Invalid character in exponent"); - - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x..p1"), "String contains multiple dots"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x..0p1"), "String contains multiple dots"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x1.0.0p1"), "String contains multiple dots"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x"), "Invalid string"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x"), "Invalid string"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x"), "Invalid string"); + + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x0"), "Hex strings require an exponent"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x0"), "Hex strings require an exponent"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x0"), "Hex strings require an exponent"); + + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x0."), "Hex strings require an exponent"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x0."), "Hex strings require an exponent"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x0."), "Hex strings require an exponent"); + + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x.0"), "Hex strings require an exponent"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x.0"), "Hex strings require an exponent"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x.0"), "Hex strings require an exponent"); + + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x0.0"), "Hex strings require an exponent"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x0.0"), "Hex strings require an exponent"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x0.0"), "Hex strings require an exponent"); + + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), StringRef("0x\0", 3)), "Invalid character in significand"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), StringRef("0x1\0", 4)), "Invalid character in significand"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), StringRef("0x1\02", 5)), "Invalid character in significand"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), StringRef("0x1\02p1", 7)), "Invalid character in significand"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), StringRef("0x1p\0", 5)), "Invalid character in exponent"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), StringRef("0x1p1\0", 6)), "Invalid character in exponent"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), StringRef("0x1p1\02", 7)), "Invalid character in exponent"); + + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x1p0f"), "Invalid character in exponent"); + + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x..p1"), "String contains multiple dots"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x..0p1"), "String contains multiple dots"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x1.0.0p1"), "String contains multiple dots"); } TEST(APFloatTest, StringHexadecimalSignificandDeath) { - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x."), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x."), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x."), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x."), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x."), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x."), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0xp"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0xp"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0xp"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0xp"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0xp"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0xp"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0xp+"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0xp+"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0xp+"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0xp+"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0xp+"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0xp+"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0xp-"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0xp-"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0xp-"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0xp-"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0xp-"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0xp-"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x.p"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x.p"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x.p"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x.p"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x.p"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x.p"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x.p+"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x.p+"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x.p+"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x.p+"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x.p+"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x.p+"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x.p-"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x.p-"), "Significand has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x.p-"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x.p-"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x.p-"), "Significand has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x.p-"), "Significand has no digits"); } TEST(APFloatTest, StringHexadecimalExponentDeath) { - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x1p"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x1p"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x1p"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x1p"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x1p"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x1p"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x1p+"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x1p+"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x1p+"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x1p+"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x1p+"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x1p+"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x1p-"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x1p-"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x1p-"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x1p-"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x1p-"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x1p-"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x1.p"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x1.p"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x1.p"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x1.p"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x1.p"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x1.p"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x1.p+"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x1.p+"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x1.p+"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x1.p+"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x1.p+"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x1.p+"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x1.p-"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x1.p-"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x1.p-"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x1.p-"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x1.p-"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x1.p-"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x.1p"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x.1p"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x.1p"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x.1p"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x.1p"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x.1p"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x.1p+"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x.1p+"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x.1p+"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x.1p+"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x.1p+"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x.1p+"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x.1p-"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x.1p-"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x.1p-"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x.1p-"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x.1p-"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x.1p-"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x1.1p"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x1.1p"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x1.1p"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x1.1p"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x1.1p"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x1.1p"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x1.1p+"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x1.1p+"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x1.1p+"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x1.1p+"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x1.1p+"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x1.1p+"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x1.1p-"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "+0x1.1p-"), "Exponent has no digits"); - EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x1.1p-"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x1.1p-"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x1.1p-"), "Exponent has no digits"); + EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x1.1p-"), "Exponent has no digits"); } #endif #endif @@ -1236,12 +1236,12 @@ EXPECT_TRUE(inv.bitwiseIsEqual(APFloat(0.5))); EXPECT_TRUE(APFloat(2.0f).getExactInverse(&inv)); EXPECT_TRUE(inv.bitwiseIsEqual(APFloat(0.5f))); - EXPECT_TRUE(APFloat(APFloat::IEEEquad, "2.0").getExactInverse(&inv)); - EXPECT_TRUE(inv.bitwiseIsEqual(APFloat(APFloat::IEEEquad, "0.5"))); - EXPECT_TRUE(APFloat(APFloat::PPCDoubleDouble, "2.0").getExactInverse(&inv)); - EXPECT_TRUE(inv.bitwiseIsEqual(APFloat(APFloat::PPCDoubleDouble, "0.5"))); - EXPECT_TRUE(APFloat(APFloat::x87DoubleExtended, "2.0").getExactInverse(&inv)); - EXPECT_TRUE(inv.bitwiseIsEqual(APFloat(APFloat::x87DoubleExtended, "0.5"))); + EXPECT_TRUE(APFloat(APFloat::IEEEquad(), "2.0").getExactInverse(&inv)); + EXPECT_TRUE(inv.bitwiseIsEqual(APFloat(APFloat::IEEEquad(), "0.5"))); + EXPECT_TRUE(APFloat(APFloat::PPCDoubleDouble(), "2.0").getExactInverse(&inv)); + EXPECT_TRUE(inv.bitwiseIsEqual(APFloat(APFloat::PPCDoubleDouble(), "0.5"))); + EXPECT_TRUE(APFloat(APFloat::x87DoubleExtended(), "2.0").getExactInverse(&inv)); + EXPECT_TRUE(inv.bitwiseIsEqual(APFloat(APFloat::x87DoubleExtended(), "0.5"))); // FLT_MIN EXPECT_TRUE(APFloat(1.17549435e-38f).getExactInverse(&inv)); @@ -1256,7 +1256,7 @@ } TEST(APFloatTest, roundToIntegral) { - APFloat T(-0.5), S(3.14), R(APFloat::getLargest(APFloat::IEEEdouble)), P(0.0); + APFloat T(-0.5), S(3.14), R(APFloat::getLargest(APFloat::IEEEdouble())), P(0.0); P = T; P.roundToIntegral(APFloat::rmTowardZero); @@ -1297,19 +1297,19 @@ P.roundToIntegral(APFloat::rmNearestTiesToEven); EXPECT_EQ(R.convertToDouble(), P.convertToDouble()); - P = APFloat::getZero(APFloat::IEEEdouble); + P = APFloat::getZero(APFloat::IEEEdouble()); P.roundToIntegral(APFloat::rmTowardZero); EXPECT_EQ(0.0, P.convertToDouble()); - P = APFloat::getZero(APFloat::IEEEdouble, true); + P = APFloat::getZero(APFloat::IEEEdouble(), true); P.roundToIntegral(APFloat::rmTowardZero); EXPECT_EQ(-0.0, P.convertToDouble()); - P = APFloat::getNaN(APFloat::IEEEdouble); + P = APFloat::getNaN(APFloat::IEEEdouble()); P.roundToIntegral(APFloat::rmTowardZero); EXPECT_TRUE(std::isnan(P.convertToDouble())); - P = APFloat::getInf(APFloat::IEEEdouble); + P = APFloat::getInf(APFloat::IEEEdouble()); P.roundToIntegral(APFloat::rmTowardZero); EXPECT_TRUE(std::isinf(P.convertToDouble()) && P.convertToDouble() > 0.0); - P = APFloat::getInf(APFloat::IEEEdouble, true); + P = APFloat::getInf(APFloat::IEEEdouble(), true); P.roundToIntegral(APFloat::rmTowardZero); EXPECT_TRUE(std::isinf(P.convertToDouble()) && P.convertToDouble() < 0.0); } @@ -1319,45 +1319,45 @@ EXPECT_TRUE(T.isInteger()); T = APFloat(3.14159); EXPECT_FALSE(T.isInteger()); - T = APFloat::getNaN(APFloat::IEEEdouble); + T = APFloat::getNaN(APFloat::IEEEdouble()); EXPECT_FALSE(T.isInteger()); - T = APFloat::getInf(APFloat::IEEEdouble); + T = APFloat::getInf(APFloat::IEEEdouble()); EXPECT_FALSE(T.isInteger()); - T = APFloat::getInf(APFloat::IEEEdouble, true); + T = APFloat::getInf(APFloat::IEEEdouble(), true); EXPECT_FALSE(T.isInteger()); - T = APFloat::getLargest(APFloat::IEEEdouble); + T = APFloat::getLargest(APFloat::IEEEdouble()); EXPECT_TRUE(T.isInteger()); } TEST(APFloatTest, getLargest) { - EXPECT_EQ(3.402823466e+38f, APFloat::getLargest(APFloat::IEEEsingle).convertToFloat()); - EXPECT_EQ(1.7976931348623158e+308, APFloat::getLargest(APFloat::IEEEdouble).convertToDouble()); + EXPECT_EQ(3.402823466e+38f, APFloat::getLargest(APFloat::IEEEsingle()).convertToFloat()); + EXPECT_EQ(1.7976931348623158e+308, APFloat::getLargest(APFloat::IEEEdouble()).convertToDouble()); } TEST(APFloatTest, getSmallest) { - APFloat test = APFloat::getSmallest(APFloat::IEEEsingle, false); - APFloat expected = APFloat(APFloat::IEEEsingle, "0x0.000002p-126"); + APFloat test = APFloat::getSmallest(APFloat::IEEEsingle(), false); + APFloat expected = APFloat(APFloat::IEEEsingle(), "0x0.000002p-126"); EXPECT_FALSE(test.isNegative()); EXPECT_TRUE(test.isFiniteNonZero()); EXPECT_TRUE(test.isDenormal()); EXPECT_TRUE(test.bitwiseIsEqual(expected)); - test = APFloat::getSmallest(APFloat::IEEEsingle, true); - expected = APFloat(APFloat::IEEEsingle, "-0x0.000002p-126"); + test = APFloat::getSmallest(APFloat::IEEEsingle(), true); + expected = APFloat(APFloat::IEEEsingle(), "-0x0.000002p-126"); EXPECT_TRUE(test.isNegative()); EXPECT_TRUE(test.isFiniteNonZero()); EXPECT_TRUE(test.isDenormal()); EXPECT_TRUE(test.bitwiseIsEqual(expected)); - test = APFloat::getSmallest(APFloat::IEEEquad, false); - expected = APFloat(APFloat::IEEEquad, "0x0.0000000000000000000000000001p-16382"); + test = APFloat::getSmallest(APFloat::IEEEquad(), false); + expected = APFloat(APFloat::IEEEquad(), "0x0.0000000000000000000000000001p-16382"); EXPECT_FALSE(test.isNegative()); EXPECT_TRUE(test.isFiniteNonZero()); EXPECT_TRUE(test.isDenormal()); EXPECT_TRUE(test.bitwiseIsEqual(expected)); - test = APFloat::getSmallest(APFloat::IEEEquad, true); - expected = APFloat(APFloat::IEEEquad, "-0x0.0000000000000000000000000001p-16382"); + test = APFloat::getSmallest(APFloat::IEEEquad(), true); + expected = APFloat(APFloat::IEEEquad(), "-0x0.0000000000000000000000000001p-16382"); EXPECT_TRUE(test.isNegative()); EXPECT_TRUE(test.isFiniteNonZero()); EXPECT_TRUE(test.isDenormal()); @@ -1365,29 +1365,29 @@ } TEST(APFloatTest, getSmallestNormalized) { - APFloat test = APFloat::getSmallestNormalized(APFloat::IEEEsingle, false); - APFloat expected = APFloat(APFloat::IEEEsingle, "0x1p-126"); + APFloat test = APFloat::getSmallestNormalized(APFloat::IEEEsingle(), false); + APFloat expected = APFloat(APFloat::IEEEsingle(), "0x1p-126"); EXPECT_FALSE(test.isNegative()); EXPECT_TRUE(test.isFiniteNonZero()); EXPECT_FALSE(test.isDenormal()); EXPECT_TRUE(test.bitwiseIsEqual(expected)); - test = APFloat::getSmallestNormalized(APFloat::IEEEsingle, true); - expected = APFloat(APFloat::IEEEsingle, "-0x1p-126"); + test = APFloat::getSmallestNormalized(APFloat::IEEEsingle(), true); + expected = APFloat(APFloat::IEEEsingle(), "-0x1p-126"); EXPECT_TRUE(test.isNegative()); EXPECT_TRUE(test.isFiniteNonZero()); EXPECT_FALSE(test.isDenormal()); EXPECT_TRUE(test.bitwiseIsEqual(expected)); - test = APFloat::getSmallestNormalized(APFloat::IEEEquad, false); - expected = APFloat(APFloat::IEEEquad, "0x1p-16382"); + test = APFloat::getSmallestNormalized(APFloat::IEEEquad(), false); + expected = APFloat(APFloat::IEEEquad(), "0x1p-16382"); EXPECT_FALSE(test.isNegative()); EXPECT_TRUE(test.isFiniteNonZero()); EXPECT_FALSE(test.isDenormal()); EXPECT_TRUE(test.bitwiseIsEqual(expected)); - test = APFloat::getSmallestNormalized(APFloat::IEEEquad, true); - expected = APFloat(APFloat::IEEEquad, "-0x1p-16382"); + test = APFloat::getSmallestNormalized(APFloat::IEEEquad(), true); + expected = APFloat(APFloat::IEEEquad(), "-0x1p-16382"); EXPECT_TRUE(test.isNegative()); EXPECT_TRUE(test.isFiniteNonZero()); EXPECT_FALSE(test.isDenormal()); @@ -1401,18 +1401,18 @@ const unsigned long long bitPattern[2]; const unsigned bitPatternLength; } const GetZeroTest[] = { - { &APFloat::IEEEhalf, false, {0, 0}, 1}, - { &APFloat::IEEEhalf, true, {0x8000ULL, 0}, 1}, - { &APFloat::IEEEsingle, false, {0, 0}, 1}, - { &APFloat::IEEEsingle, true, {0x80000000ULL, 0}, 1}, - { &APFloat::IEEEdouble, false, {0, 0}, 1}, - { &APFloat::IEEEdouble, true, {0x8000000000000000ULL, 0}, 1}, - { &APFloat::IEEEquad, false, {0, 0}, 2}, - { &APFloat::IEEEquad, true, {0, 0x8000000000000000ULL}, 2}, - { &APFloat::PPCDoubleDouble, false, {0, 0}, 2}, - { &APFloat::PPCDoubleDouble, true, {0x8000000000000000ULL, 0}, 2}, - { &APFloat::x87DoubleExtended, false, {0, 0}, 2}, - { &APFloat::x87DoubleExtended, true, {0, 0x8000ULL}, 2}, + { &APFloat::IEEEhalf(), false, {0, 0}, 1}, + { &APFloat::IEEEhalf(), true, {0x8000ULL, 0}, 1}, + { &APFloat::IEEEsingle(), false, {0, 0}, 1}, + { &APFloat::IEEEsingle(), true, {0x80000000ULL, 0}, 1}, + { &APFloat::IEEEdouble(), false, {0, 0}, 1}, + { &APFloat::IEEEdouble(), true, {0x8000000000000000ULL, 0}, 1}, + { &APFloat::IEEEquad(), false, {0, 0}, 2}, + { &APFloat::IEEEquad(), true, {0, 0x8000000000000000ULL}, 2}, + { &APFloat::PPCDoubleDouble(), false, {0, 0}, 2}, + { &APFloat::PPCDoubleDouble(), true, {0x8000000000000000ULL, 0}, 2}, + { &APFloat::x87DoubleExtended(), false, {0, 0}, 2}, + { &APFloat::x87DoubleExtended(), true, {0, 0x8000ULL}, 2}, }; const unsigned NumGetZeroTests = 12; for (unsigned i = 0; i < NumGetZeroTests; ++i) { @@ -1444,81 +1444,81 @@ TEST(APFloatTest, convert) { bool losesInfo; - APFloat test(APFloat::IEEEdouble, "1.0"); - test.convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven, &losesInfo); + APFloat test(APFloat::IEEEdouble(), "1.0"); + test.convert(APFloat::IEEEsingle(), APFloat::rmNearestTiesToEven, &losesInfo); EXPECT_EQ(1.0f, test.convertToFloat()); EXPECT_FALSE(losesInfo); - test = APFloat(APFloat::x87DoubleExtended, "0x1p-53"); - test.add(APFloat(APFloat::x87DoubleExtended, "1.0"), APFloat::rmNearestTiesToEven); - test.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven, &losesInfo); + test = APFloat(APFloat::x87DoubleExtended(), "0x1p-53"); + test.add(APFloat(APFloat::x87DoubleExtended(), "1.0"), APFloat::rmNearestTiesToEven); + test.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven, &losesInfo); EXPECT_EQ(1.0, test.convertToDouble()); EXPECT_TRUE(losesInfo); - test = APFloat(APFloat::IEEEquad, "0x1p-53"); - test.add(APFloat(APFloat::IEEEquad, "1.0"), APFloat::rmNearestTiesToEven); - test.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven, &losesInfo); + test = APFloat(APFloat::IEEEquad(), "0x1p-53"); + test.add(APFloat(APFloat::IEEEquad(), "1.0"), APFloat::rmNearestTiesToEven); + test.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven, &losesInfo); EXPECT_EQ(1.0, test.convertToDouble()); EXPECT_TRUE(losesInfo); - test = APFloat(APFloat::x87DoubleExtended, "0xf.fffffffp+28"); - test.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven, &losesInfo); + test = APFloat(APFloat::x87DoubleExtended(), "0xf.fffffffp+28"); + test.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven, &losesInfo); EXPECT_EQ(4294967295.0, test.convertToDouble()); EXPECT_FALSE(losesInfo); - test = APFloat::getSNaN(APFloat::IEEEsingle); - APFloat X87SNaN = APFloat::getSNaN(APFloat::x87DoubleExtended); - test.convert(APFloat::x87DoubleExtended, APFloat::rmNearestTiesToEven, + test = APFloat::getSNaN(APFloat::IEEEsingle()); + APFloat X87SNaN = APFloat::getSNaN(APFloat::x87DoubleExtended()); + test.convert(APFloat::x87DoubleExtended(), APFloat::rmNearestTiesToEven, &losesInfo); EXPECT_TRUE(test.bitwiseIsEqual(X87SNaN)); EXPECT_FALSE(losesInfo); - test = APFloat::getQNaN(APFloat::IEEEsingle); - APFloat X87QNaN = APFloat::getQNaN(APFloat::x87DoubleExtended); - test.convert(APFloat::x87DoubleExtended, APFloat::rmNearestTiesToEven, + test = APFloat::getQNaN(APFloat::IEEEsingle()); + APFloat X87QNaN = APFloat::getQNaN(APFloat::x87DoubleExtended()); + test.convert(APFloat::x87DoubleExtended(), APFloat::rmNearestTiesToEven, &losesInfo); EXPECT_TRUE(test.bitwiseIsEqual(X87QNaN)); EXPECT_FALSE(losesInfo); - test = APFloat::getSNaN(APFloat::x87DoubleExtended); - test.convert(APFloat::x87DoubleExtended, APFloat::rmNearestTiesToEven, + test = APFloat::getSNaN(APFloat::x87DoubleExtended()); + test.convert(APFloat::x87DoubleExtended(), APFloat::rmNearestTiesToEven, &losesInfo); EXPECT_TRUE(test.bitwiseIsEqual(X87SNaN)); EXPECT_FALSE(losesInfo); - test = APFloat::getQNaN(APFloat::x87DoubleExtended); - test.convert(APFloat::x87DoubleExtended, APFloat::rmNearestTiesToEven, + test = APFloat::getQNaN(APFloat::x87DoubleExtended()); + test.convert(APFloat::x87DoubleExtended(), APFloat::rmNearestTiesToEven, &losesInfo); EXPECT_TRUE(test.bitwiseIsEqual(X87QNaN)); EXPECT_FALSE(losesInfo); } TEST(APFloatTest, PPCDoubleDouble) { - APFloat test(APFloat::PPCDoubleDouble, "1.0"); + APFloat test(APFloat::PPCDoubleDouble(), "1.0"); EXPECT_EQ(0x3ff0000000000000ull, test.bitcastToAPInt().getRawData()[0]); EXPECT_EQ(0x0000000000000000ull, test.bitcastToAPInt().getRawData()[1]); - test.divide(APFloat(APFloat::PPCDoubleDouble, "3.0"), APFloat::rmNearestTiesToEven); + test.divide(APFloat(APFloat::PPCDoubleDouble(), "3.0"), APFloat::rmNearestTiesToEven); EXPECT_EQ(0x3fd5555555555555ull, test.bitcastToAPInt().getRawData()[0]); EXPECT_EQ(0x3c75555555555556ull, test.bitcastToAPInt().getRawData()[1]); // LDBL_MAX - test = APFloat(APFloat::PPCDoubleDouble, "1.79769313486231580793728971405301e+308"); + test = APFloat(APFloat::PPCDoubleDouble(), "1.79769313486231580793728971405301e+308"); EXPECT_EQ(0x7fefffffffffffffull, test.bitcastToAPInt().getRawData()[0]); EXPECT_EQ(0x7c8ffffffffffffeull, test.bitcastToAPInt().getRawData()[1]); // LDBL_MIN - test = APFloat(APFloat::PPCDoubleDouble, "2.00416836000897277799610805135016e-292"); + test = APFloat(APFloat::PPCDoubleDouble(), "2.00416836000897277799610805135016e-292"); EXPECT_EQ(0x0360000000000000ull, test.bitcastToAPInt().getRawData()[0]); EXPECT_EQ(0x0000000000000000ull, test.bitcastToAPInt().getRawData()[1]); - test = APFloat(APFloat::PPCDoubleDouble, "1.0"); - test.add(APFloat(APFloat::PPCDoubleDouble, "0x1p-105"), APFloat::rmNearestTiesToEven); + test = APFloat(APFloat::PPCDoubleDouble(), "1.0"); + test.add(APFloat(APFloat::PPCDoubleDouble(), "0x1p-105"), APFloat::rmNearestTiesToEven); EXPECT_EQ(0x3ff0000000000000ull, test.bitcastToAPInt().getRawData()[0]); EXPECT_EQ(0x3960000000000000ull, test.bitcastToAPInt().getRawData()[1]); - test = APFloat(APFloat::PPCDoubleDouble, "1.0"); - test.add(APFloat(APFloat::PPCDoubleDouble, "0x1p-106"), APFloat::rmNearestTiesToEven); + test = APFloat(APFloat::PPCDoubleDouble(), "1.0"); + test.add(APFloat(APFloat::PPCDoubleDouble(), "0x1p-106"), APFloat::rmNearestTiesToEven); EXPECT_EQ(0x3ff0000000000000ull, test.bitcastToAPInt().getRawData()[0]); #if 0 // XFAIL // This is what we would expect with a true double-double implementation @@ -1530,119 +1530,119 @@ // PR30869 { - auto Result = APFloat(APFloat::PPCDoubleDouble, "1.0") + - APFloat(APFloat::PPCDoubleDouble, "1.0"); - EXPECT_EQ(&APFloat::PPCDoubleDouble, &Result.getSemantics()); + auto Result = APFloat(APFloat::PPCDoubleDouble(), "1.0") + + APFloat(APFloat::PPCDoubleDouble(), "1.0"); + EXPECT_EQ(&APFloat::PPCDoubleDouble(), &Result.getSemantics()); - Result = APFloat(APFloat::PPCDoubleDouble, "1.0") - - APFloat(APFloat::PPCDoubleDouble, "1.0"); - EXPECT_EQ(&APFloat::PPCDoubleDouble, &Result.getSemantics()); + Result = APFloat(APFloat::PPCDoubleDouble(), "1.0") - + APFloat(APFloat::PPCDoubleDouble(), "1.0"); + EXPECT_EQ(&APFloat::PPCDoubleDouble(), &Result.getSemantics()); - Result = APFloat(APFloat::PPCDoubleDouble, "1.0") * - APFloat(APFloat::PPCDoubleDouble, "1.0"); - EXPECT_EQ(&APFloat::PPCDoubleDouble, &Result.getSemantics()); + Result = APFloat(APFloat::PPCDoubleDouble(), "1.0") * + APFloat(APFloat::PPCDoubleDouble(), "1.0"); + EXPECT_EQ(&APFloat::PPCDoubleDouble(), &Result.getSemantics()); - Result = APFloat(APFloat::PPCDoubleDouble, "1.0") / - APFloat(APFloat::PPCDoubleDouble, "1.0"); - EXPECT_EQ(&APFloat::PPCDoubleDouble, &Result.getSemantics()); + Result = APFloat(APFloat::PPCDoubleDouble(), "1.0") / + APFloat(APFloat::PPCDoubleDouble(), "1.0"); + EXPECT_EQ(&APFloat::PPCDoubleDouble(), &Result.getSemantics()); int Exp; - Result = frexp(APFloat(APFloat::PPCDoubleDouble, "1.0"), Exp, + Result = frexp(APFloat(APFloat::PPCDoubleDouble(), "1.0"), Exp, APFloat::rmNearestTiesToEven); - EXPECT_EQ(&APFloat::PPCDoubleDouble, &Result.getSemantics()); + EXPECT_EQ(&APFloat::PPCDoubleDouble(), &Result.getSemantics()); - Result = scalbn(APFloat(APFloat::PPCDoubleDouble, "1.0"), 1, + Result = scalbn(APFloat(APFloat::PPCDoubleDouble(), "1.0"), 1, APFloat::rmNearestTiesToEven); - EXPECT_EQ(&APFloat::PPCDoubleDouble, &Result.getSemantics()); + EXPECT_EQ(&APFloat::PPCDoubleDouble(), &Result.getSemantics()); } } TEST(APFloatTest, isNegative) { - APFloat t(APFloat::IEEEsingle, "0x1p+0"); + APFloat t(APFloat::IEEEsingle(), "0x1p+0"); EXPECT_FALSE(t.isNegative()); - t = APFloat(APFloat::IEEEsingle, "-0x1p+0"); + t = APFloat(APFloat::IEEEsingle(), "-0x1p+0"); EXPECT_TRUE(t.isNegative()); - EXPECT_FALSE(APFloat::getInf(APFloat::IEEEsingle, false).isNegative()); - EXPECT_TRUE(APFloat::getInf(APFloat::IEEEsingle, true).isNegative()); + EXPECT_FALSE(APFloat::getInf(APFloat::IEEEsingle(), false).isNegative()); + EXPECT_TRUE(APFloat::getInf(APFloat::IEEEsingle(), true).isNegative()); - EXPECT_FALSE(APFloat::getZero(APFloat::IEEEsingle, false).isNegative()); - EXPECT_TRUE(APFloat::getZero(APFloat::IEEEsingle, true).isNegative()); + EXPECT_FALSE(APFloat::getZero(APFloat::IEEEsingle(), false).isNegative()); + EXPECT_TRUE(APFloat::getZero(APFloat::IEEEsingle(), true).isNegative()); - EXPECT_FALSE(APFloat::getNaN(APFloat::IEEEsingle, false).isNegative()); - EXPECT_TRUE(APFloat::getNaN(APFloat::IEEEsingle, true).isNegative()); + EXPECT_FALSE(APFloat::getNaN(APFloat::IEEEsingle(), false).isNegative()); + EXPECT_TRUE(APFloat::getNaN(APFloat::IEEEsingle(), true).isNegative()); - EXPECT_FALSE(APFloat::getSNaN(APFloat::IEEEsingle, false).isNegative()); - EXPECT_TRUE(APFloat::getSNaN(APFloat::IEEEsingle, true).isNegative()); + EXPECT_FALSE(APFloat::getSNaN(APFloat::IEEEsingle(), false).isNegative()); + EXPECT_TRUE(APFloat::getSNaN(APFloat::IEEEsingle(), true).isNegative()); } TEST(APFloatTest, isNormal) { - APFloat t(APFloat::IEEEsingle, "0x1p+0"); + APFloat t(APFloat::IEEEsingle(), "0x1p+0"); EXPECT_TRUE(t.isNormal()); - EXPECT_FALSE(APFloat::getInf(APFloat::IEEEsingle, false).isNormal()); - EXPECT_FALSE(APFloat::getZero(APFloat::IEEEsingle, false).isNormal()); - EXPECT_FALSE(APFloat::getNaN(APFloat::IEEEsingle, false).isNormal()); - EXPECT_FALSE(APFloat::getSNaN(APFloat::IEEEsingle, false).isNormal()); - EXPECT_FALSE(APFloat(APFloat::IEEEsingle, "0x1p-149").isNormal()); + EXPECT_FALSE(APFloat::getInf(APFloat::IEEEsingle(), false).isNormal()); + EXPECT_FALSE(APFloat::getZero(APFloat::IEEEsingle(), false).isNormal()); + EXPECT_FALSE(APFloat::getNaN(APFloat::IEEEsingle(), false).isNormal()); + EXPECT_FALSE(APFloat::getSNaN(APFloat::IEEEsingle(), false).isNormal()); + EXPECT_FALSE(APFloat(APFloat::IEEEsingle(), "0x1p-149").isNormal()); } TEST(APFloatTest, isFinite) { - APFloat t(APFloat::IEEEsingle, "0x1p+0"); + APFloat t(APFloat::IEEEsingle(), "0x1p+0"); EXPECT_TRUE(t.isFinite()); - EXPECT_FALSE(APFloat::getInf(APFloat::IEEEsingle, false).isFinite()); - EXPECT_TRUE(APFloat::getZero(APFloat::IEEEsingle, false).isFinite()); - EXPECT_FALSE(APFloat::getNaN(APFloat::IEEEsingle, false).isFinite()); - EXPECT_FALSE(APFloat::getSNaN(APFloat::IEEEsingle, false).isFinite()); - EXPECT_TRUE(APFloat(APFloat::IEEEsingle, "0x1p-149").isFinite()); + EXPECT_FALSE(APFloat::getInf(APFloat::IEEEsingle(), false).isFinite()); + EXPECT_TRUE(APFloat::getZero(APFloat::IEEEsingle(), false).isFinite()); + EXPECT_FALSE(APFloat::getNaN(APFloat::IEEEsingle(), false).isFinite()); + EXPECT_FALSE(APFloat::getSNaN(APFloat::IEEEsingle(), false).isFinite()); + EXPECT_TRUE(APFloat(APFloat::IEEEsingle(), "0x1p-149").isFinite()); } TEST(APFloatTest, isInfinity) { - APFloat t(APFloat::IEEEsingle, "0x1p+0"); + APFloat t(APFloat::IEEEsingle(), "0x1p+0"); EXPECT_FALSE(t.isInfinity()); - EXPECT_TRUE(APFloat::getInf(APFloat::IEEEsingle, false).isInfinity()); - EXPECT_FALSE(APFloat::getZero(APFloat::IEEEsingle, false).isInfinity()); - EXPECT_FALSE(APFloat::getNaN(APFloat::IEEEsingle, false).isInfinity()); - EXPECT_FALSE(APFloat::getSNaN(APFloat::IEEEsingle, false).isInfinity()); - EXPECT_FALSE(APFloat(APFloat::IEEEsingle, "0x1p-149").isInfinity()); + EXPECT_TRUE(APFloat::getInf(APFloat::IEEEsingle(), false).isInfinity()); + EXPECT_FALSE(APFloat::getZero(APFloat::IEEEsingle(), false).isInfinity()); + EXPECT_FALSE(APFloat::getNaN(APFloat::IEEEsingle(), false).isInfinity()); + EXPECT_FALSE(APFloat::getSNaN(APFloat::IEEEsingle(), false).isInfinity()); + EXPECT_FALSE(APFloat(APFloat::IEEEsingle(), "0x1p-149").isInfinity()); } TEST(APFloatTest, isNaN) { - APFloat t(APFloat::IEEEsingle, "0x1p+0"); + APFloat t(APFloat::IEEEsingle(), "0x1p+0"); EXPECT_FALSE(t.isNaN()); - EXPECT_FALSE(APFloat::getInf(APFloat::IEEEsingle, false).isNaN()); - EXPECT_FALSE(APFloat::getZero(APFloat::IEEEsingle, false).isNaN()); - EXPECT_TRUE(APFloat::getNaN(APFloat::IEEEsingle, false).isNaN()); - EXPECT_TRUE(APFloat::getSNaN(APFloat::IEEEsingle, false).isNaN()); - EXPECT_FALSE(APFloat(APFloat::IEEEsingle, "0x1p-149").isNaN()); + EXPECT_FALSE(APFloat::getInf(APFloat::IEEEsingle(), false).isNaN()); + EXPECT_FALSE(APFloat::getZero(APFloat::IEEEsingle(), false).isNaN()); + EXPECT_TRUE(APFloat::getNaN(APFloat::IEEEsingle(), false).isNaN()); + EXPECT_TRUE(APFloat::getSNaN(APFloat::IEEEsingle(), false).isNaN()); + EXPECT_FALSE(APFloat(APFloat::IEEEsingle(), "0x1p-149").isNaN()); } TEST(APFloatTest, isFiniteNonZero) { // Test positive/negative normal value. - EXPECT_TRUE(APFloat(APFloat::IEEEsingle, "0x1p+0").isFiniteNonZero()); - EXPECT_TRUE(APFloat(APFloat::IEEEsingle, "-0x1p+0").isFiniteNonZero()); + EXPECT_TRUE(APFloat(APFloat::IEEEsingle(), "0x1p+0").isFiniteNonZero()); + EXPECT_TRUE(APFloat(APFloat::IEEEsingle(), "-0x1p+0").isFiniteNonZero()); // Test positive/negative denormal value. - EXPECT_TRUE(APFloat(APFloat::IEEEsingle, "0x1p-149").isFiniteNonZero()); - EXPECT_TRUE(APFloat(APFloat::IEEEsingle, "-0x1p-149").isFiniteNonZero()); + EXPECT_TRUE(APFloat(APFloat::IEEEsingle(), "0x1p-149").isFiniteNonZero()); + EXPECT_TRUE(APFloat(APFloat::IEEEsingle(), "-0x1p-149").isFiniteNonZero()); // Test +/- Infinity. - EXPECT_FALSE(APFloat::getInf(APFloat::IEEEsingle, false).isFiniteNonZero()); - EXPECT_FALSE(APFloat::getInf(APFloat::IEEEsingle, true).isFiniteNonZero()); + EXPECT_FALSE(APFloat::getInf(APFloat::IEEEsingle(), false).isFiniteNonZero()); + EXPECT_FALSE(APFloat::getInf(APFloat::IEEEsingle(), true).isFiniteNonZero()); // Test +/- Zero. - EXPECT_FALSE(APFloat::getZero(APFloat::IEEEsingle, false).isFiniteNonZero()); - EXPECT_FALSE(APFloat::getZero(APFloat::IEEEsingle, true).isFiniteNonZero()); + EXPECT_FALSE(APFloat::getZero(APFloat::IEEEsingle(), false).isFiniteNonZero()); + EXPECT_FALSE(APFloat::getZero(APFloat::IEEEsingle(), true).isFiniteNonZero()); // Test +/- qNaN. +/- dont mean anything with qNaN but paranoia can't hurt in // this instance. - EXPECT_FALSE(APFloat::getNaN(APFloat::IEEEsingle, false).isFiniteNonZero()); - EXPECT_FALSE(APFloat::getNaN(APFloat::IEEEsingle, true).isFiniteNonZero()); + EXPECT_FALSE(APFloat::getNaN(APFloat::IEEEsingle(), false).isFiniteNonZero()); + EXPECT_FALSE(APFloat::getNaN(APFloat::IEEEsingle(), true).isFiniteNonZero()); // Test +/- sNaN. +/- dont mean anything with sNaN but paranoia can't hurt in // this instance. - EXPECT_FALSE(APFloat::getSNaN(APFloat::IEEEsingle, false).isFiniteNonZero()); - EXPECT_FALSE(APFloat::getSNaN(APFloat::IEEEsingle, true).isFiniteNonZero()); + EXPECT_FALSE(APFloat::getSNaN(APFloat::IEEEsingle(), false).isFiniteNonZero()); + EXPECT_FALSE(APFloat::getSNaN(APFloat::IEEEsingle(), true).isFiniteNonZero()); } TEST(APFloatTest, add) { @@ -1653,22 +1653,22 @@ // signaling NaNs should have a result that is a quiet NaN. Currently they // return sNaN. - APFloat PInf = APFloat::getInf(APFloat::IEEEsingle, false); - APFloat MInf = APFloat::getInf(APFloat::IEEEsingle, true); - APFloat PZero = APFloat::getZero(APFloat::IEEEsingle, false); - APFloat MZero = APFloat::getZero(APFloat::IEEEsingle, true); - APFloat QNaN = APFloat::getNaN(APFloat::IEEEsingle, false); - APFloat SNaN = APFloat::getSNaN(APFloat::IEEEsingle, false); - APFloat PNormalValue = APFloat(APFloat::IEEEsingle, "0x1p+0"); - APFloat MNormalValue = APFloat(APFloat::IEEEsingle, "-0x1p+0"); - APFloat PLargestValue = APFloat::getLargest(APFloat::IEEEsingle, false); - APFloat MLargestValue = APFloat::getLargest(APFloat::IEEEsingle, true); - APFloat PSmallestValue = APFloat::getSmallest(APFloat::IEEEsingle, false); - APFloat MSmallestValue = APFloat::getSmallest(APFloat::IEEEsingle, true); + APFloat PInf = APFloat::getInf(APFloat::IEEEsingle(), false); + APFloat MInf = APFloat::getInf(APFloat::IEEEsingle(), true); + APFloat PZero = APFloat::getZero(APFloat::IEEEsingle(), false); + APFloat MZero = APFloat::getZero(APFloat::IEEEsingle(), true); + APFloat QNaN = APFloat::getNaN(APFloat::IEEEsingle(), false); + APFloat SNaN = APFloat::getSNaN(APFloat::IEEEsingle(), false); + APFloat PNormalValue = APFloat(APFloat::IEEEsingle(), "0x1p+0"); + APFloat MNormalValue = APFloat(APFloat::IEEEsingle(), "-0x1p+0"); + APFloat PLargestValue = APFloat::getLargest(APFloat::IEEEsingle(), false); + APFloat MLargestValue = APFloat::getLargest(APFloat::IEEEsingle(), true); + APFloat PSmallestValue = APFloat::getSmallest(APFloat::IEEEsingle(), false); + APFloat MSmallestValue = APFloat::getSmallest(APFloat::IEEEsingle(), true); APFloat PSmallestNormalized = - APFloat::getSmallestNormalized(APFloat::IEEEsingle, false); + APFloat::getSmallestNormalized(APFloat::IEEEsingle(), false); APFloat MSmallestNormalized = - APFloat::getSmallestNormalized(APFloat::IEEEsingle, true); + APFloat::getSmallestNormalized(APFloat::IEEEsingle(), true); const int OverflowStatus = APFloat::opOverflow | APFloat::opInexact; @@ -1925,7 +1925,7 @@ APFloat y(SpecialCaseTests[i].y); APFloat::opStatus status = x.add(y, APFloat::rmNearestTiesToEven); - APFloat result(APFloat::IEEEsingle, SpecialCaseTests[i].result); + APFloat result(APFloat::IEEEsingle(), SpecialCaseTests[i].result); EXPECT_TRUE(result.bitwiseIsEqual(x)); EXPECT_TRUE((int)status == SpecialCaseTests[i].status); @@ -1941,22 +1941,22 @@ // signaling NaNs should have a result that is a quiet NaN. Currently they // return sNaN. - APFloat PInf = APFloat::getInf(APFloat::IEEEsingle, false); - APFloat MInf = APFloat::getInf(APFloat::IEEEsingle, true); - APFloat PZero = APFloat::getZero(APFloat::IEEEsingle, false); - APFloat MZero = APFloat::getZero(APFloat::IEEEsingle, true); - APFloat QNaN = APFloat::getNaN(APFloat::IEEEsingle, false); - APFloat SNaN = APFloat::getSNaN(APFloat::IEEEsingle, false); - APFloat PNormalValue = APFloat(APFloat::IEEEsingle, "0x1p+0"); - APFloat MNormalValue = APFloat(APFloat::IEEEsingle, "-0x1p+0"); - APFloat PLargestValue = APFloat::getLargest(APFloat::IEEEsingle, false); - APFloat MLargestValue = APFloat::getLargest(APFloat::IEEEsingle, true); - APFloat PSmallestValue = APFloat::getSmallest(APFloat::IEEEsingle, false); - APFloat MSmallestValue = APFloat::getSmallest(APFloat::IEEEsingle, true); + APFloat PInf = APFloat::getInf(APFloat::IEEEsingle(), false); + APFloat MInf = APFloat::getInf(APFloat::IEEEsingle(), true); + APFloat PZero = APFloat::getZero(APFloat::IEEEsingle(), false); + APFloat MZero = APFloat::getZero(APFloat::IEEEsingle(), true); + APFloat QNaN = APFloat::getNaN(APFloat::IEEEsingle(), false); + APFloat SNaN = APFloat::getSNaN(APFloat::IEEEsingle(), false); + APFloat PNormalValue = APFloat(APFloat::IEEEsingle(), "0x1p+0"); + APFloat MNormalValue = APFloat(APFloat::IEEEsingle(), "-0x1p+0"); + APFloat PLargestValue = APFloat::getLargest(APFloat::IEEEsingle(), false); + APFloat MLargestValue = APFloat::getLargest(APFloat::IEEEsingle(), true); + APFloat PSmallestValue = APFloat::getSmallest(APFloat::IEEEsingle(), false); + APFloat MSmallestValue = APFloat::getSmallest(APFloat::IEEEsingle(), true); APFloat PSmallestNormalized = - APFloat::getSmallestNormalized(APFloat::IEEEsingle, false); + APFloat::getSmallestNormalized(APFloat::IEEEsingle(), false); APFloat MSmallestNormalized = - APFloat::getSmallestNormalized(APFloat::IEEEsingle, true); + APFloat::getSmallestNormalized(APFloat::IEEEsingle(), true); const int OverflowStatus = APFloat::opOverflow | APFloat::opInexact; @@ -2213,7 +2213,7 @@ APFloat y(SpecialCaseTests[i].y); APFloat::opStatus status = x.subtract(y, APFloat::rmNearestTiesToEven); - APFloat result(APFloat::IEEEsingle, SpecialCaseTests[i].result); + APFloat result(APFloat::IEEEsingle(), SpecialCaseTests[i].result); EXPECT_TRUE(result.bitwiseIsEqual(x)); EXPECT_TRUE((int)status == SpecialCaseTests[i].status); @@ -2229,22 +2229,22 @@ // signaling NaNs should have a result that is a quiet NaN. Currently they // return sNaN. - APFloat PInf = APFloat::getInf(APFloat::IEEEsingle, false); - APFloat MInf = APFloat::getInf(APFloat::IEEEsingle, true); - APFloat PZero = APFloat::getZero(APFloat::IEEEsingle, false); - APFloat MZero = APFloat::getZero(APFloat::IEEEsingle, true); - APFloat QNaN = APFloat::getNaN(APFloat::IEEEsingle, false); - APFloat SNaN = APFloat::getSNaN(APFloat::IEEEsingle, false); - APFloat PNormalValue = APFloat(APFloat::IEEEsingle, "0x1p+0"); - APFloat MNormalValue = APFloat(APFloat::IEEEsingle, "-0x1p+0"); - APFloat PLargestValue = APFloat::getLargest(APFloat::IEEEsingle, false); - APFloat MLargestValue = APFloat::getLargest(APFloat::IEEEsingle, true); - APFloat PSmallestValue = APFloat::getSmallest(APFloat::IEEEsingle, false); - APFloat MSmallestValue = APFloat::getSmallest(APFloat::IEEEsingle, true); + APFloat PInf = APFloat::getInf(APFloat::IEEEsingle(), false); + APFloat MInf = APFloat::getInf(APFloat::IEEEsingle(), true); + APFloat PZero = APFloat::getZero(APFloat::IEEEsingle(), false); + APFloat MZero = APFloat::getZero(APFloat::IEEEsingle(), true); + APFloat QNaN = APFloat::getNaN(APFloat::IEEEsingle(), false); + APFloat SNaN = APFloat::getSNaN(APFloat::IEEEsingle(), false); + APFloat PNormalValue = APFloat(APFloat::IEEEsingle(), "0x1p+0"); + APFloat MNormalValue = APFloat(APFloat::IEEEsingle(), "-0x1p+0"); + APFloat PLargestValue = APFloat::getLargest(APFloat::IEEEsingle(), false); + APFloat MLargestValue = APFloat::getLargest(APFloat::IEEEsingle(), true); + APFloat PSmallestValue = APFloat::getSmallest(APFloat::IEEEsingle(), false); + APFloat MSmallestValue = APFloat::getSmallest(APFloat::IEEEsingle(), true); APFloat PSmallestNormalized = - APFloat::getSmallestNormalized(APFloat::IEEEsingle, false); + APFloat::getSmallestNormalized(APFloat::IEEEsingle(), false); APFloat MSmallestNormalized = - APFloat::getSmallestNormalized(APFloat::IEEEsingle, true); + APFloat::getSmallestNormalized(APFloat::IEEEsingle(), true); const int OverflowStatus = APFloat::opOverflow | APFloat::opInexact; const int UnderflowStatus = APFloat::opUnderflow | APFloat::opInexact; @@ -2502,7 +2502,7 @@ APFloat y(SpecialCaseTests[i].y); APFloat::opStatus status = x.multiply(y, APFloat::rmNearestTiesToEven); - APFloat result(APFloat::IEEEsingle, SpecialCaseTests[i].result); + APFloat result(APFloat::IEEEsingle(), SpecialCaseTests[i].result); EXPECT_TRUE(result.bitwiseIsEqual(x)); EXPECT_TRUE((int)status == SpecialCaseTests[i].status); @@ -2518,22 +2518,22 @@ // signaling NaNs should have a result that is a quiet NaN. Currently they // return sNaN. - APFloat PInf = APFloat::getInf(APFloat::IEEEsingle, false); - APFloat MInf = APFloat::getInf(APFloat::IEEEsingle, true); - APFloat PZero = APFloat::getZero(APFloat::IEEEsingle, false); - APFloat MZero = APFloat::getZero(APFloat::IEEEsingle, true); - APFloat QNaN = APFloat::getNaN(APFloat::IEEEsingle, false); - APFloat SNaN = APFloat::getSNaN(APFloat::IEEEsingle, false); - APFloat PNormalValue = APFloat(APFloat::IEEEsingle, "0x1p+0"); - APFloat MNormalValue = APFloat(APFloat::IEEEsingle, "-0x1p+0"); - APFloat PLargestValue = APFloat::getLargest(APFloat::IEEEsingle, false); - APFloat MLargestValue = APFloat::getLargest(APFloat::IEEEsingle, true); - APFloat PSmallestValue = APFloat::getSmallest(APFloat::IEEEsingle, false); - APFloat MSmallestValue = APFloat::getSmallest(APFloat::IEEEsingle, true); + APFloat PInf = APFloat::getInf(APFloat::IEEEsingle(), false); + APFloat MInf = APFloat::getInf(APFloat::IEEEsingle(), true); + APFloat PZero = APFloat::getZero(APFloat::IEEEsingle(), false); + APFloat MZero = APFloat::getZero(APFloat::IEEEsingle(), true); + APFloat QNaN = APFloat::getNaN(APFloat::IEEEsingle(), false); + APFloat SNaN = APFloat::getSNaN(APFloat::IEEEsingle(), false); + APFloat PNormalValue = APFloat(APFloat::IEEEsingle(), "0x1p+0"); + APFloat MNormalValue = APFloat(APFloat::IEEEsingle(), "-0x1p+0"); + APFloat PLargestValue = APFloat::getLargest(APFloat::IEEEsingle(), false); + APFloat MLargestValue = APFloat::getLargest(APFloat::IEEEsingle(), true); + APFloat PSmallestValue = APFloat::getSmallest(APFloat::IEEEsingle(), false); + APFloat MSmallestValue = APFloat::getSmallest(APFloat::IEEEsingle(), true); APFloat PSmallestNormalized = - APFloat::getSmallestNormalized(APFloat::IEEEsingle, false); + APFloat::getSmallestNormalized(APFloat::IEEEsingle(), false); APFloat MSmallestNormalized = - APFloat::getSmallestNormalized(APFloat::IEEEsingle, true); + APFloat::getSmallestNormalized(APFloat::IEEEsingle(), true); const int OverflowStatus = APFloat::opOverflow | APFloat::opInexact; const int UnderflowStatus = APFloat::opUnderflow | APFloat::opInexact; @@ -2791,7 +2791,7 @@ APFloat y(SpecialCaseTests[i].y); APFloat::opStatus status = x.divide(y, APFloat::rmNearestTiesToEven); - APFloat result(APFloat::IEEEsingle, SpecialCaseTests[i].result); + APFloat result(APFloat::IEEEsingle(), SpecialCaseTests[i].result); EXPECT_TRUE(result.bitwiseIsEqual(x)); EXPECT_TRUE((int)status == SpecialCaseTests[i].status); @@ -2801,8 +2801,8 @@ TEST(APFloatTest, operatorOverloads) { // This is mostly testing that these operator overloads compile. - APFloat One = APFloat(APFloat::IEEEsingle, "0x1p+0"); - APFloat Two = APFloat(APFloat::IEEEsingle, "0x2p+0"); + APFloat One = APFloat(APFloat::IEEEsingle(), "0x1p+0"); + APFloat Two = APFloat(APFloat::IEEEsingle(), "0x2p+0"); EXPECT_TRUE(Two.bitwiseIsEqual(One + One)); EXPECT_TRUE(One.bitwiseIsEqual(Two - One)); EXPECT_TRUE(Two.bitwiseIsEqual(One * Two)); @@ -2810,24 +2810,24 @@ } TEST(APFloatTest, abs) { - APFloat PInf = APFloat::getInf(APFloat::IEEEsingle, false); - APFloat MInf = APFloat::getInf(APFloat::IEEEsingle, true); - APFloat PZero = APFloat::getZero(APFloat::IEEEsingle, false); - APFloat MZero = APFloat::getZero(APFloat::IEEEsingle, true); - APFloat PQNaN = APFloat::getNaN(APFloat::IEEEsingle, false); - APFloat MQNaN = APFloat::getNaN(APFloat::IEEEsingle, true); - APFloat PSNaN = APFloat::getSNaN(APFloat::IEEEsingle, false); - APFloat MSNaN = APFloat::getSNaN(APFloat::IEEEsingle, true); - APFloat PNormalValue = APFloat(APFloat::IEEEsingle, "0x1p+0"); - APFloat MNormalValue = APFloat(APFloat::IEEEsingle, "-0x1p+0"); - APFloat PLargestValue = APFloat::getLargest(APFloat::IEEEsingle, false); - APFloat MLargestValue = APFloat::getLargest(APFloat::IEEEsingle, true); - APFloat PSmallestValue = APFloat::getSmallest(APFloat::IEEEsingle, false); - APFloat MSmallestValue = APFloat::getSmallest(APFloat::IEEEsingle, true); + APFloat PInf = APFloat::getInf(APFloat::IEEEsingle(), false); + APFloat MInf = APFloat::getInf(APFloat::IEEEsingle(), true); + APFloat PZero = APFloat::getZero(APFloat::IEEEsingle(), false); + APFloat MZero = APFloat::getZero(APFloat::IEEEsingle(), true); + APFloat PQNaN = APFloat::getNaN(APFloat::IEEEsingle(), false); + APFloat MQNaN = APFloat::getNaN(APFloat::IEEEsingle(), true); + APFloat PSNaN = APFloat::getSNaN(APFloat::IEEEsingle(), false); + APFloat MSNaN = APFloat::getSNaN(APFloat::IEEEsingle(), true); + APFloat PNormalValue = APFloat(APFloat::IEEEsingle(), "0x1p+0"); + APFloat MNormalValue = APFloat(APFloat::IEEEsingle(), "-0x1p+0"); + APFloat PLargestValue = APFloat::getLargest(APFloat::IEEEsingle(), false); + APFloat MLargestValue = APFloat::getLargest(APFloat::IEEEsingle(), true); + APFloat PSmallestValue = APFloat::getSmallest(APFloat::IEEEsingle(), false); + APFloat MSmallestValue = APFloat::getSmallest(APFloat::IEEEsingle(), true); APFloat PSmallestNormalized = - APFloat::getSmallestNormalized(APFloat::IEEEsingle, false); + APFloat::getSmallestNormalized(APFloat::IEEEsingle(), false); APFloat MSmallestNormalized = - APFloat::getSmallestNormalized(APFloat::IEEEsingle, true); + APFloat::getSmallestNormalized(APFloat::IEEEsingle(), true); EXPECT_TRUE(PInf.bitwiseIsEqual(abs(PInf))); EXPECT_TRUE(PInf.bitwiseIsEqual(abs(MInf))); @@ -2848,68 +2848,68 @@ } TEST(APFloatTest, ilogb) { - EXPECT_EQ(-1074, ilogb(APFloat::getSmallest(APFloat::IEEEdouble, false))); - EXPECT_EQ(-1074, ilogb(APFloat::getSmallest(APFloat::IEEEdouble, true))); - EXPECT_EQ(-1023, ilogb(APFloat(APFloat::IEEEdouble, "0x1.ffffffffffffep-1024"))); - EXPECT_EQ(-1023, ilogb(APFloat(APFloat::IEEEdouble, "0x1.ffffffffffffep-1023"))); - EXPECT_EQ(-1023, ilogb(APFloat(APFloat::IEEEdouble, "-0x1.ffffffffffffep-1023"))); - EXPECT_EQ(-51, ilogb(APFloat(APFloat::IEEEdouble, "0x1p-51"))); - EXPECT_EQ(-1023, ilogb(APFloat(APFloat::IEEEdouble, "0x1.c60f120d9f87cp-1023"))); - EXPECT_EQ(-2, ilogb(APFloat(APFloat::IEEEdouble, "0x0.ffffp-1"))); - EXPECT_EQ(-1023, ilogb(APFloat(APFloat::IEEEdouble, "0x1.fffep-1023"))); - EXPECT_EQ(1023, ilogb(APFloat::getLargest(APFloat::IEEEdouble, false))); - EXPECT_EQ(1023, ilogb(APFloat::getLargest(APFloat::IEEEdouble, true))); - - - EXPECT_EQ(0, ilogb(APFloat(APFloat::IEEEsingle, "0x1p+0"))); - EXPECT_EQ(0, ilogb(APFloat(APFloat::IEEEsingle, "-0x1p+0"))); - EXPECT_EQ(42, ilogb(APFloat(APFloat::IEEEsingle, "0x1p+42"))); - EXPECT_EQ(-42, ilogb(APFloat(APFloat::IEEEsingle, "0x1p-42"))); + EXPECT_EQ(-1074, ilogb(APFloat::getSmallest(APFloat::IEEEdouble(), false))); + EXPECT_EQ(-1074, ilogb(APFloat::getSmallest(APFloat::IEEEdouble(), true))); + EXPECT_EQ(-1023, ilogb(APFloat(APFloat::IEEEdouble(), "0x1.ffffffffffffep-1024"))); + EXPECT_EQ(-1023, ilogb(APFloat(APFloat::IEEEdouble(), "0x1.ffffffffffffep-1023"))); + EXPECT_EQ(-1023, ilogb(APFloat(APFloat::IEEEdouble(), "-0x1.ffffffffffffep-1023"))); + EXPECT_EQ(-51, ilogb(APFloat(APFloat::IEEEdouble(), "0x1p-51"))); + EXPECT_EQ(-1023, ilogb(APFloat(APFloat::IEEEdouble(), "0x1.c60f120d9f87cp-1023"))); + EXPECT_EQ(-2, ilogb(APFloat(APFloat::IEEEdouble(), "0x0.ffffp-1"))); + EXPECT_EQ(-1023, ilogb(APFloat(APFloat::IEEEdouble(), "0x1.fffep-1023"))); + EXPECT_EQ(1023, ilogb(APFloat::getLargest(APFloat::IEEEdouble(), false))); + EXPECT_EQ(1023, ilogb(APFloat::getLargest(APFloat::IEEEdouble(), true))); + + + EXPECT_EQ(0, ilogb(APFloat(APFloat::IEEEsingle(), "0x1p+0"))); + EXPECT_EQ(0, ilogb(APFloat(APFloat::IEEEsingle(), "-0x1p+0"))); + EXPECT_EQ(42, ilogb(APFloat(APFloat::IEEEsingle(), "0x1p+42"))); + EXPECT_EQ(-42, ilogb(APFloat(APFloat::IEEEsingle(), "0x1p-42"))); EXPECT_EQ(APFloat::IEK_Inf, - ilogb(APFloat::getInf(APFloat::IEEEsingle, false))); + ilogb(APFloat::getInf(APFloat::IEEEsingle(), false))); EXPECT_EQ(APFloat::IEK_Inf, - ilogb(APFloat::getInf(APFloat::IEEEsingle, true))); + ilogb(APFloat::getInf(APFloat::IEEEsingle(), true))); EXPECT_EQ(APFloat::IEK_Zero, - ilogb(APFloat::getZero(APFloat::IEEEsingle, false))); + ilogb(APFloat::getZero(APFloat::IEEEsingle(), false))); EXPECT_EQ(APFloat::IEK_Zero, - ilogb(APFloat::getZero(APFloat::IEEEsingle, true))); + ilogb(APFloat::getZero(APFloat::IEEEsingle(), true))); EXPECT_EQ(APFloat::IEK_NaN, - ilogb(APFloat::getNaN(APFloat::IEEEsingle, false))); + ilogb(APFloat::getNaN(APFloat::IEEEsingle(), false))); EXPECT_EQ(APFloat::IEK_NaN, - ilogb(APFloat::getSNaN(APFloat::IEEEsingle, false))); + ilogb(APFloat::getSNaN(APFloat::IEEEsingle(), false))); - EXPECT_EQ(127, ilogb(APFloat::getLargest(APFloat::IEEEsingle, false))); - EXPECT_EQ(127, ilogb(APFloat::getLargest(APFloat::IEEEsingle, true))); + EXPECT_EQ(127, ilogb(APFloat::getLargest(APFloat::IEEEsingle(), false))); + EXPECT_EQ(127, ilogb(APFloat::getLargest(APFloat::IEEEsingle(), true))); - EXPECT_EQ(-149, ilogb(APFloat::getSmallest(APFloat::IEEEsingle, false))); - EXPECT_EQ(-149, ilogb(APFloat::getSmallest(APFloat::IEEEsingle, true))); + EXPECT_EQ(-149, ilogb(APFloat::getSmallest(APFloat::IEEEsingle(), false))); + EXPECT_EQ(-149, ilogb(APFloat::getSmallest(APFloat::IEEEsingle(), true))); EXPECT_EQ(-126, - ilogb(APFloat::getSmallestNormalized(APFloat::IEEEsingle, false))); + ilogb(APFloat::getSmallestNormalized(APFloat::IEEEsingle(), false))); EXPECT_EQ(-126, - ilogb(APFloat::getSmallestNormalized(APFloat::IEEEsingle, true))); + ilogb(APFloat::getSmallestNormalized(APFloat::IEEEsingle(), true))); } TEST(APFloatTest, scalbn) { const APFloat::roundingMode RM = APFloat::rmNearestTiesToEven; EXPECT_TRUE( - APFloat(APFloat::IEEEsingle, "0x1p+0") - .bitwiseIsEqual(scalbn(APFloat(APFloat::IEEEsingle, "0x1p+0"), 0, RM))); + APFloat(APFloat::IEEEsingle(), "0x1p+0") + .bitwiseIsEqual(scalbn(APFloat(APFloat::IEEEsingle(), "0x1p+0"), 0, RM))); EXPECT_TRUE( - APFloat(APFloat::IEEEsingle, "0x1p+42") - .bitwiseIsEqual(scalbn(APFloat(APFloat::IEEEsingle, "0x1p+0"), 42, RM))); + APFloat(APFloat::IEEEsingle(), "0x1p+42") + .bitwiseIsEqual(scalbn(APFloat(APFloat::IEEEsingle(), "0x1p+0"), 42, RM))); EXPECT_TRUE( - APFloat(APFloat::IEEEsingle, "0x1p-42") - .bitwiseIsEqual(scalbn(APFloat(APFloat::IEEEsingle, "0x1p+0"), -42, RM))); + APFloat(APFloat::IEEEsingle(), "0x1p-42") + .bitwiseIsEqual(scalbn(APFloat(APFloat::IEEEsingle(), "0x1p+0"), -42, RM))); - APFloat PInf = APFloat::getInf(APFloat::IEEEsingle, false); - APFloat MInf = APFloat::getInf(APFloat::IEEEsingle, true); - APFloat PZero = APFloat::getZero(APFloat::IEEEsingle, false); - APFloat MZero = APFloat::getZero(APFloat::IEEEsingle, true); - APFloat QPNaN = APFloat::getNaN(APFloat::IEEEsingle, false); - APFloat QMNaN = APFloat::getNaN(APFloat::IEEEsingle, true); - APFloat SNaN = APFloat::getSNaN(APFloat::IEEEsingle, false); + APFloat PInf = APFloat::getInf(APFloat::IEEEsingle(), false); + APFloat MInf = APFloat::getInf(APFloat::IEEEsingle(), true); + APFloat PZero = APFloat::getZero(APFloat::IEEEsingle(), false); + APFloat MZero = APFloat::getZero(APFloat::IEEEsingle(), true); + APFloat QPNaN = APFloat::getNaN(APFloat::IEEEsingle(), false); + APFloat QMNaN = APFloat::getNaN(APFloat::IEEEsingle(), true); + APFloat SNaN = APFloat::getSNaN(APFloat::IEEEsingle(), false); EXPECT_TRUE(PInf.bitwiseIsEqual(scalbn(PInf, 0, RM))); EXPECT_TRUE(MInf.bitwiseIsEqual(scalbn(MInf, 0, RM))); @@ -2928,57 +2928,57 @@ (UINT64_C(1234) << 32) | 1); - APFloat SNaNWithPayload = APFloat::getSNaN(APFloat::IEEEdouble, false, + APFloat SNaNWithPayload = APFloat::getSNaN(APFloat::IEEEdouble(), false, &Payload); APFloat QuietPayload = scalbn(SNaNWithPayload, 1, RM); EXPECT_TRUE(QuietPayload.isNaN() && !QuietPayload.isSignaling()); EXPECT_EQ(Payload, QuietPayload.bitcastToAPInt().getLoBits(51)); EXPECT_TRUE(PInf.bitwiseIsEqual( - scalbn(APFloat(APFloat::IEEEsingle, "0x1p+0"), 128, RM))); + scalbn(APFloat(APFloat::IEEEsingle(), "0x1p+0"), 128, RM))); EXPECT_TRUE(MInf.bitwiseIsEqual( - scalbn(APFloat(APFloat::IEEEsingle, "-0x1p+0"), 128, RM))); + scalbn(APFloat(APFloat::IEEEsingle(), "-0x1p+0"), 128, RM))); EXPECT_TRUE(PInf.bitwiseIsEqual( - scalbn(APFloat(APFloat::IEEEsingle, "0x1p+127"), 1, RM))); + scalbn(APFloat(APFloat::IEEEsingle(), "0x1p+127"), 1, RM))); EXPECT_TRUE(PZero.bitwiseIsEqual( - scalbn(APFloat(APFloat::IEEEsingle, "0x1p-127"), -127, RM))); + scalbn(APFloat(APFloat::IEEEsingle(), "0x1p-127"), -127, RM))); EXPECT_TRUE(MZero.bitwiseIsEqual( - scalbn(APFloat(APFloat::IEEEsingle, "-0x1p-127"), -127, RM))); - EXPECT_TRUE(APFloat(APFloat::IEEEsingle, "-0x1p-149").bitwiseIsEqual( - scalbn(APFloat(APFloat::IEEEsingle, "-0x1p-127"), -22, RM))); + scalbn(APFloat(APFloat::IEEEsingle(), "-0x1p-127"), -127, RM))); + EXPECT_TRUE(APFloat(APFloat::IEEEsingle(), "-0x1p-149").bitwiseIsEqual( + scalbn(APFloat(APFloat::IEEEsingle(), "-0x1p-127"), -22, RM))); EXPECT_TRUE(PZero.bitwiseIsEqual( - scalbn(APFloat(APFloat::IEEEsingle, "0x1p-126"), -24, RM))); + scalbn(APFloat(APFloat::IEEEsingle(), "0x1p-126"), -24, RM))); - APFloat SmallestF64 = APFloat::getSmallest(APFloat::IEEEdouble, false); - APFloat NegSmallestF64 = APFloat::getSmallest(APFloat::IEEEdouble, true); + APFloat SmallestF64 = APFloat::getSmallest(APFloat::IEEEdouble(), false); + APFloat NegSmallestF64 = APFloat::getSmallest(APFloat::IEEEdouble(), true); - APFloat LargestF64 = APFloat::getLargest(APFloat::IEEEdouble, false); - APFloat NegLargestF64 = APFloat::getLargest(APFloat::IEEEdouble, true); + APFloat LargestF64 = APFloat::getLargest(APFloat::IEEEdouble(), false); + APFloat NegLargestF64 = APFloat::getLargest(APFloat::IEEEdouble(), true); APFloat SmallestNormalizedF64 - = APFloat::getSmallestNormalized(APFloat::IEEEdouble, false); + = APFloat::getSmallestNormalized(APFloat::IEEEdouble(), false); APFloat NegSmallestNormalizedF64 - = APFloat::getSmallestNormalized(APFloat::IEEEdouble, true); + = APFloat::getSmallestNormalized(APFloat::IEEEdouble(), true); - APFloat LargestDenormalF64(APFloat::IEEEdouble, "0x1.ffffffffffffep-1023"); - APFloat NegLargestDenormalF64(APFloat::IEEEdouble, "-0x1.ffffffffffffep-1023"); + APFloat LargestDenormalF64(APFloat::IEEEdouble(), "0x1.ffffffffffffep-1023"); + APFloat NegLargestDenormalF64(APFloat::IEEEdouble(), "-0x1.ffffffffffffep-1023"); EXPECT_TRUE(SmallestF64.bitwiseIsEqual( - scalbn(APFloat(APFloat::IEEEdouble, "0x1p-1074"), 0, RM))); + scalbn(APFloat(APFloat::IEEEdouble(), "0x1p-1074"), 0, RM))); EXPECT_TRUE(NegSmallestF64.bitwiseIsEqual( - scalbn(APFloat(APFloat::IEEEdouble, "-0x1p-1074"), 0, RM))); + scalbn(APFloat(APFloat::IEEEdouble(), "-0x1p-1074"), 0, RM))); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "0x1p+1023") + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "0x1p+1023") .bitwiseIsEqual(scalbn(SmallestF64, 2097, RM))); EXPECT_TRUE(scalbn(SmallestF64, -2097, RM).isPosZero()); EXPECT_TRUE(scalbn(SmallestF64, -2098, RM).isPosZero()); EXPECT_TRUE(scalbn(SmallestF64, -2099, RM).isPosZero()); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "0x1p+1022") + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "0x1p+1022") .bitwiseIsEqual(scalbn(SmallestF64, 2096, RM))); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "0x1p+1023") + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "0x1p+1023") .bitwiseIsEqual(scalbn(SmallestF64, 2097, RM))); EXPECT_TRUE(scalbn(SmallestF64, 2098, RM).isInfinity()); EXPECT_TRUE(scalbn(SmallestF64, 2099, RM).isInfinity()); @@ -2992,12 +2992,12 @@ EXPECT_TRUE(NegLargestDenormalF64 .bitwiseIsEqual(scalbn(NegLargestDenormalF64, 0, RM))); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "0x1.ffffffffffffep-1022") + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "0x1.ffffffffffffep-1022") .bitwiseIsEqual(scalbn(LargestDenormalF64, 1, RM))); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "-0x1.ffffffffffffep-1021") + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "-0x1.ffffffffffffep-1021") .bitwiseIsEqual(scalbn(NegLargestDenormalF64, 2, RM))); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "0x1.ffffffffffffep+1") + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "0x1.ffffffffffffep+1") .bitwiseIsEqual(scalbn(LargestDenormalF64, 1024, RM))); EXPECT_TRUE(scalbn(LargestDenormalF64, -1023, RM).isPosZero()); EXPECT_TRUE(scalbn(LargestDenormalF64, -1024, RM).isPosZero()); @@ -3006,25 +3006,25 @@ EXPECT_TRUE(scalbn(LargestDenormalF64, 2098, RM).isInfinity()); EXPECT_TRUE(scalbn(LargestDenormalF64, 2099, RM).isInfinity()); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "0x1.ffffffffffffep-2") + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "0x1.ffffffffffffep-2") .bitwiseIsEqual(scalbn(LargestDenormalF64, 1021, RM))); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "0x1.ffffffffffffep-1") + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "0x1.ffffffffffffep-1") .bitwiseIsEqual(scalbn(LargestDenormalF64, 1022, RM))); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "0x1.ffffffffffffep+0") + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "0x1.ffffffffffffep+0") .bitwiseIsEqual(scalbn(LargestDenormalF64, 1023, RM))); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "0x1.ffffffffffffep+1023") + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "0x1.ffffffffffffep+1023") .bitwiseIsEqual(scalbn(LargestDenormalF64, 2046, RM))); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "0x1p+974") + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "0x1p+974") .bitwiseIsEqual(scalbn(SmallestF64, 2048, RM))); - APFloat RandomDenormalF64(APFloat::IEEEdouble, "0x1.c60f120d9f87cp+51"); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "0x1.c60f120d9f87cp-972") + APFloat RandomDenormalF64(APFloat::IEEEdouble(), "0x1.c60f120d9f87cp+51"); + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "0x1.c60f120d9f87cp-972") .bitwiseIsEqual(scalbn(RandomDenormalF64, -1023, RM))); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "0x1.c60f120d9f87cp-1") + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "0x1.c60f120d9f87cp-1") .bitwiseIsEqual(scalbn(RandomDenormalF64, -52, RM))); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "0x1.c60f120d9f87cp-2") + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "0x1.c60f120d9f87cp-2") .bitwiseIsEqual(scalbn(RandomDenormalF64, -53, RM))); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "0x1.c60f120d9f87cp+0") + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "0x1.c60f120d9f87cp+0") .bitwiseIsEqual(scalbn(RandomDenormalF64, -51, RM))); EXPECT_TRUE(scalbn(RandomDenormalF64, -2097, RM).isPosZero()); @@ -3032,60 +3032,60 @@ EXPECT_TRUE( - APFloat(APFloat::IEEEdouble, "-0x1p-1073") + APFloat(APFloat::IEEEdouble(), "-0x1p-1073") .bitwiseIsEqual(scalbn(NegLargestF64, -2097, RM))); EXPECT_TRUE( - APFloat(APFloat::IEEEdouble, "-0x1p-1024") + APFloat(APFloat::IEEEdouble(), "-0x1p-1024") .bitwiseIsEqual(scalbn(NegLargestF64, -2048, RM))); EXPECT_TRUE( - APFloat(APFloat::IEEEdouble, "0x1p-1073") + APFloat(APFloat::IEEEdouble(), "0x1p-1073") .bitwiseIsEqual(scalbn(LargestF64, -2097, RM))); EXPECT_TRUE( - APFloat(APFloat::IEEEdouble, "0x1p-1074") + APFloat(APFloat::IEEEdouble(), "0x1p-1074") .bitwiseIsEqual(scalbn(LargestF64, -2098, RM))); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "-0x1p-1074") + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "-0x1p-1074") .bitwiseIsEqual(scalbn(NegLargestF64, -2098, RM))); EXPECT_TRUE(scalbn(NegLargestF64, -2099, RM).isNegZero()); EXPECT_TRUE(scalbn(LargestF64, 1, RM).isInfinity()); EXPECT_TRUE( - APFloat(APFloat::IEEEdouble, "0x1p+0") - .bitwiseIsEqual(scalbn(APFloat(APFloat::IEEEdouble, "0x1p+52"), -52, RM))); + APFloat(APFloat::IEEEdouble(), "0x1p+0") + .bitwiseIsEqual(scalbn(APFloat(APFloat::IEEEdouble(), "0x1p+52"), -52, RM))); EXPECT_TRUE( - APFloat(APFloat::IEEEdouble, "0x1p-103") - .bitwiseIsEqual(scalbn(APFloat(APFloat::IEEEdouble, "0x1p-51"), -52, RM))); + APFloat(APFloat::IEEEdouble(), "0x1p-103") + .bitwiseIsEqual(scalbn(APFloat(APFloat::IEEEdouble(), "0x1p-51"), -52, RM))); } TEST(APFloatTest, frexp) { const APFloat::roundingMode RM = APFloat::rmNearestTiesToEven; - APFloat PZero = APFloat::getZero(APFloat::IEEEdouble, false); - APFloat MZero = APFloat::getZero(APFloat::IEEEdouble, true); + APFloat PZero = APFloat::getZero(APFloat::IEEEdouble(), false); + APFloat MZero = APFloat::getZero(APFloat::IEEEdouble(), true); APFloat One(1.0); APFloat MOne(-1.0); APFloat Two(2.0); APFloat MTwo(-2.0); - APFloat LargestDenormal(APFloat::IEEEdouble, "0x1.ffffffffffffep-1023"); - APFloat NegLargestDenormal(APFloat::IEEEdouble, "-0x1.ffffffffffffep-1023"); + APFloat LargestDenormal(APFloat::IEEEdouble(), "0x1.ffffffffffffep-1023"); + APFloat NegLargestDenormal(APFloat::IEEEdouble(), "-0x1.ffffffffffffep-1023"); - APFloat Smallest = APFloat::getSmallest(APFloat::IEEEdouble, false); - APFloat NegSmallest = APFloat::getSmallest(APFloat::IEEEdouble, true); + APFloat Smallest = APFloat::getSmallest(APFloat::IEEEdouble(), false); + APFloat NegSmallest = APFloat::getSmallest(APFloat::IEEEdouble(), true); - APFloat Largest = APFloat::getLargest(APFloat::IEEEdouble, false); - APFloat NegLargest = APFloat::getLargest(APFloat::IEEEdouble, true); + APFloat Largest = APFloat::getLargest(APFloat::IEEEdouble(), false); + APFloat NegLargest = APFloat::getLargest(APFloat::IEEEdouble(), true); - APFloat PInf = APFloat::getInf(APFloat::IEEEdouble, false); - APFloat MInf = APFloat::getInf(APFloat::IEEEdouble, true); + APFloat PInf = APFloat::getInf(APFloat::IEEEdouble(), false); + APFloat MInf = APFloat::getInf(APFloat::IEEEdouble(), true); - APFloat QPNaN = APFloat::getNaN(APFloat::IEEEdouble, false); - APFloat QMNaN = APFloat::getNaN(APFloat::IEEEdouble, true); - APFloat SNaN = APFloat::getSNaN(APFloat::IEEEdouble, false); + APFloat QPNaN = APFloat::getNaN(APFloat::IEEEdouble(), false); + APFloat QMNaN = APFloat::getNaN(APFloat::IEEEdouble(), true); + APFloat SNaN = APFloat::getSNaN(APFloat::IEEEdouble(), false); // Make sure highest bit of payload is preserved. const APInt Payload(64, (UINT64_C(1) << 50) | @@ -3093,16 +3093,16 @@ (UINT64_C(1234) << 32) | 1); - APFloat SNaNWithPayload = APFloat::getSNaN(APFloat::IEEEdouble, false, + APFloat SNaNWithPayload = APFloat::getSNaN(APFloat::IEEEdouble(), false, &Payload); APFloat SmallestNormalized - = APFloat::getSmallestNormalized(APFloat::IEEEdouble, false); + = APFloat::getSmallestNormalized(APFloat::IEEEdouble(), false); APFloat NegSmallestNormalized - = APFloat::getSmallestNormalized(APFloat::IEEEdouble, true); + = APFloat::getSmallestNormalized(APFloat::IEEEdouble(), true); int Exp; - APFloat Frac(APFloat::IEEEdouble); + APFloat Frac(APFloat::IEEEdouble()); Frac = frexp(PZero, Exp, RM); @@ -3116,37 +3116,37 @@ Frac = frexp(One, Exp, RM); EXPECT_EQ(1, Exp); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "0x1p-1").bitwiseIsEqual(Frac)); + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "0x1p-1").bitwiseIsEqual(Frac)); Frac = frexp(MOne, Exp, RM); EXPECT_EQ(1, Exp); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "-0x1p-1").bitwiseIsEqual(Frac)); + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "-0x1p-1").bitwiseIsEqual(Frac)); Frac = frexp(LargestDenormal, Exp, RM); EXPECT_EQ(-1022, Exp); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "0x1.ffffffffffffep-1").bitwiseIsEqual(Frac)); + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "0x1.ffffffffffffep-1").bitwiseIsEqual(Frac)); Frac = frexp(NegLargestDenormal, Exp, RM); EXPECT_EQ(-1022, Exp); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "-0x1.ffffffffffffep-1").bitwiseIsEqual(Frac)); + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "-0x1.ffffffffffffep-1").bitwiseIsEqual(Frac)); Frac = frexp(Smallest, Exp, RM); EXPECT_EQ(-1073, Exp); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "0x1p-1").bitwiseIsEqual(Frac)); + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "0x1p-1").bitwiseIsEqual(Frac)); Frac = frexp(NegSmallest, Exp, RM); EXPECT_EQ(-1073, Exp); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "-0x1p-1").bitwiseIsEqual(Frac)); + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "-0x1p-1").bitwiseIsEqual(Frac)); Frac = frexp(Largest, Exp, RM); EXPECT_EQ(1024, Exp); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "0x1.fffffffffffffp-1").bitwiseIsEqual(Frac)); + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "0x1.fffffffffffffp-1").bitwiseIsEqual(Frac)); Frac = frexp(NegLargest, Exp, RM); EXPECT_EQ(1024, Exp); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "-0x1.fffffffffffffp-1").bitwiseIsEqual(Frac)); + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "-0x1.fffffffffffffp-1").bitwiseIsEqual(Frac)); Frac = frexp(PInf, Exp, RM); @@ -3174,16 +3174,16 @@ EXPECT_TRUE(Frac.isNaN() && !Frac.isSignaling()); EXPECT_EQ(Payload, Frac.bitcastToAPInt().getLoBits(51)); - Frac = frexp(APFloat(APFloat::IEEEdouble, "0x0.ffffp-1"), Exp, RM); + Frac = frexp(APFloat(APFloat::IEEEdouble(), "0x0.ffffp-1"), Exp, RM); EXPECT_EQ(-1, Exp); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "0x1.fffep-1").bitwiseIsEqual(Frac)); + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "0x1.fffep-1").bitwiseIsEqual(Frac)); - Frac = frexp(APFloat(APFloat::IEEEdouble, "0x1p-51"), Exp, RM); + Frac = frexp(APFloat(APFloat::IEEEdouble(), "0x1p-51"), Exp, RM); EXPECT_EQ(-50, Exp); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "0x1p-1").bitwiseIsEqual(Frac)); + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "0x1p-1").bitwiseIsEqual(Frac)); - Frac = frexp(APFloat(APFloat::IEEEdouble, "0x1.c60f120d9f87cp+51"), Exp, RM); + Frac = frexp(APFloat(APFloat::IEEEdouble(), "0x1.c60f120d9f87cp+51"), Exp, RM); EXPECT_EQ(52, Exp); - EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "0x1.c60f120d9f87cp-1").bitwiseIsEqual(Frac)); + EXPECT_TRUE(APFloat(APFloat::IEEEdouble(), "0x1.c60f120d9f87cp-1").bitwiseIsEqual(Frac)); } }