当参数为 Integer 时,Double 值会被 floor-ed
Double value is getting floor-ed when parameter is an Integer
如果我有 {"myparam": 12.8} 并且我的请求 class 有
整数参数;
myparam 设置为 12 而不是 13。
为什么是底数而不是四舍五入?
这是从 Double 请求 int 值的预期行为(如 Double API 中所示):
public abstract int intValue()
Returns the value of the specified number as an int. This may involve
rounding or truncation.
Returns:
the numeric value represented by this object after conversion to type int.
最简单的解释方法 - 当从双精度数中获取一个整数时,包括“.”在内的所有内容都是正确的。被切碎了。
如果我有 {"myparam": 12.8} 并且我的请求 class 有
整数参数;
myparam 设置为 12 而不是 13。
为什么是底数而不是四舍五入?
这是从 Double 请求 int 值的预期行为(如 Double API 中所示):
public abstract int intValue()
Returns the value of the specified number as an int. This may involve
rounding or truncation.
Returns:
the numeric value represented by this object after conversion to type int.
最简单的解释方法 - 当从双精度数中获取一个整数时,包括“.”在内的所有内容都是正确的。被切碎了。