本文整理汇总了TypeScript中decimal.js.Decimal类的典型用法代码示例。如果您正苦于以下问题:TypeScript js.Decimal类的具体用法?TypeScript js.Decimal怎么用?TypeScript js.Decimal使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了js.Decimal类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: fromRadians
public static fromRadians(angleInRadians: Decimal, rpnCalculator: RpnCalculator): Decimal {
switch (rpnCalculator.getOption(RpnCalculator.OPTION_ANGLE_MODE)) {
case AngleMode.Radians:
return angleInRadians;
case AngleMode.Degrees:
return angleInRadians.times(180.0).dividedBy(PiOperator.PI);
default:
throw new Error(`unhandled angle mode: ${rpnCalculator.getOption(RpnCalculator.OPTION_ANGLE_MODE)}`);
}
}
示例2: executeUnaryOnAngle
protected executeUnaryOnAngle(angleInRadians: Decimal, rpnCalculator: RpnCalculator) {
return angleInRadians.sin();
}
示例3: executeUnaryAngleResult
protected executeUnaryAngleResult(a: Decimal, rpnCalculator: RpnCalculator) {
return a.asin();
}
示例4: executeBinary
protected async executeBinary(a: StackItem, b: StackItem, rpnCalculator: RpnCalculator): Promise<Decimal> {
const aVal = await a.decimalValue(rpnCalculator);
const bVal = await b.decimalValue(rpnCalculator);
return AngleOutputUnaryOperator.fromRadians(Decimal.atan2(aVal, bVal), rpnCalculator);
}