Java 中的浮點十六進位制
對於浮點十六進位制形式,使用格式說明符 %a。
對於 Formatter,匯入以下包 −
import java.util.Formatter;
現在像這樣建立 Formatter 物件 −
Formatter f = new Formatter();
將 format() 方法用於浮點十六進位制 −
f.format("%a", 298.45)以下是示例 −
示例
import java.util.Formatter;
public class Demo {
public static void main(String args[]) {
Formatter f = new Formatter();
// Floating-point hexadecimal form
System.out.println(f.format("%a", 298.45));
}
}輸出
0x1.2a73333333333p8
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP