浮點數據轉換指令包括不同的浮點精度數之間的轉換,還包括整型和浮點數之間的轉化。
在了解數據轉換指令前,必須學習 IEEE 754 定義的五種舍入規則。前兩條規則舍入到最接近的值,其他的稱為定向舍入:
舍入到最接近的值
-
Round to nearest, ties to even – rounds to the nearest value; if the number falls midway, it is rounded to the nearest value with an even least significant digit.(四舍五入到最接近的值;如果數字落在中間,則會四舍五入到最接近的具有偶數最低有效數字的值)
-
Round to nearest, ties away from zero (or ties to away) – rounds to the nearest value; if the number falls midway, it is rounded to the nearest value above (for positive numbers) or below (for negative numbers).(舍入到最接近的值;如果數字落在中間,則四舍五入到上方(對于正數)或下方(對于負數)最接近的值)
定向舍入
-
Round toward 0 – directed rounding towards zero (also known as truncation).(向零定向舍入(也稱為截斷))