BigDecimalオブジェクトを指数形式を使用する文字列表現に変換するにはどうすればよいですか?次のようなもの:3.134e67
?私はAPIを見て、私はtoEngineeringString()
を見つけましたが、それは私が欲しいものを私に与えてくれません。BigDecimalを指数関数形式に変換するにはどうすればよいですか?
答えて
が、これがDecimalFormatはからで、あなたはのNumberFormatのドキュメントを読んでいる: 参照してください:http://docs.oracle.com/javase/1.4.2/docs/api/java/text/DecimalFormat.html
Scientific Notation
Numbers in scientific notation are expressed as the product of a mantissa and a power of ten, for example, 1234 can be expressed as 1.234 x 10^3. The mantissa is often in the range 1.0 <= x < 10.0, but it need not be. DecimalFormat can be instructed to format and parse scientific notation only via a pattern; there is currently no factory method that creates a scientific notation format. In a pattern, the exponent character immediately followed by one or more digit characters indicates scientific notation. Example: "0.###E0" formats the number 1234 as "1.234E3".
The number of digit characters after the exponent character gives the minimum exponent digit count. There is no maximum. Negative exponents are formatted using the localized minus sign, not the prefix and suffix from the pattern. This allows patterns such as "0.###E0 m/s".
The minimum and maximum number of integer digits are interpreted together:
If the maximum number of integer digits is greater than their minimum number and greater than 1, it forces the exponent to be a multiple of the maximum number of integer digits, and the minimum number of integer digits to be interpreted as 1. The most common use of this is to generate engineering notation, in which the exponent is a multiple of three, e.g., "##0.#####E0". Using this pattern, the number 12345 formats to "12.345E3", and 123456 formats to "123.456E3".
Otherwise, the minimum number of integer digits is achieved by adjusting the exponent. Example: 0.0formatted with "00.###E0" yields "12.3E-4".
The number of significant digits in the mantissa is the sum of the minimum integer and maximum fraction digits, and is unaffected by the maximum integer digits. For example, 12345 formatted with "##0.##E0" is "12.3E3". To show all digits, set the significant digits count to zero. The number of significant digits does not affect parsing.
Exponential patterns may not contain grouping separators.
このようなものをお探しですか?
YY^XX(モッズQQ)
int fastMod(int YY, int XX, int QQ){
int ZZ; //declare variables
int RR = 1;
while (XX != 0){ //while XX != 0
ZZ = XX % 2; //mod XX by 2
XX= XX/2; //divide XX by 2
if (ZZ == 1) //if ZZ is one
RR = (RR * YY) % QQ; //mod (RR*YY) by QQ
YY= (YY * YY) % QQ; //mod (YY*YY) by QQ
}
return RR; //return int
}
あなたはGIANTの数字を使用して起動すると、あなたがモジュラー算術演算を使用する必要があります。 これは、RSAアルゴリズムのように大きな素数を生成する場合に特に便利になります。ここでカバーモジュラー算術の 基礎: http://www.brainjammer.com/math/modular-arithmetic/
私はそれを取得しません。これはBigDecimalを指数関数形式に変換する際にどのように役立ちますか? –
重要なのは、モジュラ算術を使用しない限り、大きな数字では扱えないことです。 –
は、このヘルプあなたをしていますか?
BigDecimal bd = new BigDecimal(3.134e67);
String.valueOf(bd.doubleValue())
- 1. 特定の形式の数値を整数に変換するにはどうすればよいですか?
- 2. 変換関数をラムダ式に変換するにはどうすればよいですか?
- 3. 数式を個々の変数の式に変換するにはどうすればよいですか?
- 4. 乱数を別の基本形式に変換するにはどうすればよいですか?
- 5. phpの日付形式をGMT形式に変換するにはどうすればよいですか?
- 6. 変換関数を式ツリーに挿入するにはどうすればよいですか?
- 7. 無名関数をMATLABのシンボリック関数に変換するにはどうすればよいですか?
- 8. MathTypeの式をMathML形式に変換するにはどうすればよいですか?
- 9. PostgreSQL(9.1)関数内で文字を整数に変換するにはどうすればよいですか?
- 10. C#でxml形式のキーペアをPEM形式に変更するにはどうすればよいですか?
- 11. 文字変数を任意のSAS形式の数値変数の書式付き値と同じにするにはどうすればよいですか?
- 12. Javaが2倍の指数形式に変換する理由
- 13. ios5でNSStringをJSON形式に変換するにはどうすればよいですか?
- 14. Eclipseの日付変数形式を設定するにはどうすればよいですか?
- 15. 数式ツリーを縮小フォームに変換するにはどうすればよいですか?
- 16. 数式(総和)をコードに変換するにはどうすればよいですか?
- 17. Javascriptで非指数/短い形式の倍数を変換/表現する
- 18. Rデータフレームを単純な形式のHTMLテーブルに変換するにはどうすればよいですか?
- 19. .mfdファイルを別の形式に変換するにはどうすればよいですか?
- 20. 式を論理和正規形に変換するにはどうすればよいですか?
- 21. jarファイルをapk形式に変換するにはどうすればよいですか?
- 22. SQL Serverの日付形式をOracleに変換するにはどうすればよいですか?
- 23. インデックス付きピクセル形式のイメージを32ビットイメージに変換するにはどうすればよいですか?
- 24. XMLをSTEP(p21)形式に変換するにはどうすればよいですか?
- 25. Perlのパック 'Nc *'形式をPythonのstruct.packに変換するにはどうすればよいですか?
- 26. 入力ファイルのデータを日付形式に変換するにはどうすればよいですか?
- 27. .CSR/p10/PKCS#10ファイルをjavaの.DER形式に変換するにはどうすればよいですか?
- 28. HTMLを文書形式に変換するにはどうすればよいですか?
- 29. パブリックRSAキー(テキスト形式)をプライベートPPKキーファイルに変換するにはどうすればよいですか?
- 30. SERIESSUM関数をVB6に変換するにはどうすればよいですか?
私はこれを試しました: 'BigDecimal d = new BigDecimal(" 55 "); DecimalFormat df =新しいDecimalFormat( "0。### E0"); System.out.println(df.format(d.toString())); '、しかし、私にエラーが表示されます:"指定されたオブジェクトを数値としてフォーマットできません " –
これで動作します。 'と' d'。ありがとう:) –