case RoundingMode::UNUM_ROUND_DOWN: // round toward zero returntrue;
case RoundingMode::UNUM_ROUND_CEILING: // round toward positive infinity return isNegative;
case RoundingMode::UNUM_ROUND_FLOOR: // round toward negative infinity return !isNegative;
case RoundingMode::UNUM_ROUND_HALFUP: switch (section) { case SECTION_MIDPOINT: returnfalse; case SECTION_LOWER: returntrue; case SECTION_UPPER: returnfalse; default: break;
} break;
case RoundingMode::UNUM_ROUND_HALFDOWN: switch (section) { case SECTION_MIDPOINT: returntrue; case SECTION_LOWER: returntrue; case SECTION_UPPER: returnfalse; default: break;
} break;
case RoundingMode::UNUM_ROUND_HALFEVEN: switch (section) { case SECTION_MIDPOINT: return isEven; case SECTION_LOWER: returntrue; case SECTION_UPPER: returnfalse; default: break;
} break;
case RoundingMode::UNUM_ROUND_HALF_ODD: switch (section) { case SECTION_MIDPOINT: return !isEven; case SECTION_LOWER: returntrue; case SECTION_UPPER: returnfalse; default: break;
} break;
case RoundingMode::UNUM_ROUND_HALF_CEILING: switch (section) { case SECTION_MIDPOINT: return isNegative; case SECTION_LOWER: returntrue; case SECTION_UPPER: returnfalse; default: break;
} break;
case RoundingMode::UNUM_ROUND_HALF_FLOOR: switch (section) { case SECTION_MIDPOINT: return !isNegative; case SECTION_LOWER: returntrue; case SECTION_UPPER: returnfalse; default: break;
} break;
default: break;
}
status = U_FORMAT_INEXACT_ERROR; returnfalse;
}
/** *Getswhetherthegivenroundingmode'sroundingboundaryisatthemidpoint.Therounding *boundaryisthepointatwhichanumberswitchesfrombeingroundeddowntobeingroundedup. *Forexample,withroundingmodeHALF_EVEN,HALF_UP,orHALF_DOWN,theroundingboundaryisat *themidpoint,andthisfunctionwouldreturntrue.However,forUP,DOWN,CEILING,andFLOOR, *theroundingboundaryisatthe"edge",andthisfunctionwouldreturnfalse. * *@paramroundingModeTheintegerversionofthe{@linkRoundingMode}. *@returntrueifroundingmodeisHALF_EVEN,HALF_UP,orHALF_DOWN;falseotherwise.
*/ inlinebool roundsAtMidpoint(int roundingMode) { switch (roundingMode) { case RoundingMode::UNUM_ROUND_UP: case RoundingMode::UNUM_ROUND_DOWN: case RoundingMode::UNUM_ROUND_CEILING: case RoundingMode::UNUM_ROUND_FLOOR: returnfalse;
default: returntrue;
}
}
} // namespace roundingutils
/** *EncapsulatesaPrecisionandaRoundingModeandperformsroundingonaDecimalQuantity. * *ThisclassdoesnotexistinJava:instead,thebasePrecisionclassisused.
*/ class RoundingImpl { public:
RoundingImpl() = default; // defaults to pass-through rounder
/** Version of {@link #apply} that obeys minInt constraints. Used for scientific notation compatibility mode. */ void apply(impl::DecimalQuantity &value, int32_t minInt, UErrorCode status);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.