* standard Integer -> FP IEEE754 conversion (used by most languages and CPUs)
* standard OpenPower FP -> Integer conversion (saturation with NaN
converted to minimum valid integer)
-* Rust FP -> Integer conversion (saturation with NaN converted to 0)
+* Java FP -> Integer conversion (saturation with NaN converted to 0)
* JavaScript FP -> Integer conversion (modular with Inf/NaN converted to 0)
The assembly listings in the [[int_fp_mv/appendix]] show how costly
* rounding mode read from FPSCR
* rounding mode always set to truncate
-### Rust FP -> Integer conversion
+### Java FP -> Integer conversion
-For the sake of simplicity, the FP -> Integer conversion semantics generalized from those used by Rust's `as` operator will be referred to as [Rust conversion semantics](#fp-to-int-rust-conversion-semantics).
+For the sake of simplicity, the FP -> Integer conversion semantics generalized from those used by Java's semantics (and Rust's `as` operator) will be referred to as
+[Java conversion semantics](#fp-to-int-java-conversion-semantics).
Those same semantics are used in some way by all of the following languages (not necessarily for the default conversion method):
-* Rust's FP -> Integer conversion using the
- [`as` operator](https://doc.rust-lang.org/reference/expressions/operator-expr.html#semantics)
* Java's
[FP -> Integer conversion](https://docs.oracle.com/javase/specs/jls/se16/html/jls-5.html#jls-5.1.3)
+* Rust's FP -> Integer conversion using the
+ [`as` operator](https://doc.rust-lang.org/reference/expressions/operator-expr.html#semantics)
* LLVM's
[`llvm.fptosi.sat`](https://llvm.org/docs/LangRef.html#llvm-fptosi-sat-intrinsic) and
[`llvm.fptoui.sat`](https://llvm.org/docs/LangRef.html#llvm-fptoui-sat-intrinsic) intrinsics
|------|-----------------|----------------------------------|
| 000 | from `FPSCR` | [OpenPower semantics] |
| 001 | Truncate | [OpenPower semantics] |
-| 010 | from `FPSCR` | [Rust semantics] |
-| 011 | Truncate | [Rust semantics] |
+| 010 | from `FPSCR` | [Java semantics] |
+| 011 | Truncate | [Java semantics] |
| 100 | from `FPSCR` | [JavaScript semantics] |
| 101 | Truncate | [JavaScript semantics] |
| rest | -- | illegal instruction trap for now |
[OpenPower semantics]: #fp-to-int-openpower-conversion-semantics
-[Rust semantics]: #fp-to-int-rust-conversion-semantics
+[Java semantics]: #fp-to-int-java-conversion-semantics
[JavaScript semantics]: #fp-to-int-javascript-conversion-semantics
* `fcvttgw RT, FRA, Mode`
return (int)rint(v, rounding_mode)
```
-<div id="fp-to-int-rust-conversion-semantics"></div>
-Rust [conversion semantics](https://doc.rust-lang.org/reference/expressions/operator-expr.html#semantics) (with adjustment to add non-truncate rounding modes):
+<div id="fp-to-int-java-conversion-semantics"></div>
+[Java conversion semantics]((https://docs.oracle.com/javase/specs/jls/se16/html/jls-5.html#jls-5.1.3))
+/
+[Rust semantics](https://doc.rust-lang.org/reference/expressions/operator-expr.html#semantics)
+(with adjustment to add non-truncate rounding modes):
```
-def fp_to_int_rust<fp, int>(v: fp) -> int:
+def fp_to_int_java<fp, int>(v: fp) -> int:
if v is NaN:
return 0
if v >= int::MAX_VALUE: