strictmath_Java StrictMath scalb()方法与示例
strictmath
StrictMath類scalb()方法 (StrictMath Class scalb() method)
Syntax:
句法:
public static double scalb(double do , int sf);public static float scalb(float fl , int sf);scalb(double do , int sf) method is used to return do* 2 raised to the power of sf rounded as an argument as passed in the method.
scalb(double do,int sf)方法用于將do * 2提升為sf的冪,該整數作為方法中傳遞的參數進行舍入。
scalb(double do , int sf) –
scalb(double do,int sf) –
- If the exponent lies in between Double.MIN_EXPONENT and Double.MAX_EXPONENT and in that case the result is exactly calculated.
- 如果指數位于Double.MIN_EXPONENT和Double.MAX_EXPONENT之間,則在這種情況下,將精確計算結果。
- If the exponent answer would be greater than Double.MAX_EXPONENT and in that case infinity is returned.
- 如果指數答案大于Double.MAX_EXPONENT ,則返回無窮大。
- scalb(float fl , int sf) method is used to return fl* 2 raised to the power of sf rounded as an argument as passed in the method.
- scalb(float fl,int sf)方法用于返回fl * 2 ,該值被提升為sf的冪,該整數作為方法中傳遞的參數進行舍入。
scalb(float fl , int sf) –
scalb(float fl,int sf) –
- If the exponent lies in between Float.MIN_EXPONENT and Float.MAX_EXPONENT and in that case the result is exactly calculated.
- 如果指數位于Float.MIN_EXPONENT和Float.MAX_EXPONENT之間, 那么在這種情況下,結果將被精確計算。
- If the exponent answer would be greater than Float.MAX_EXPONENT and in that case infinity is returned.
- 如果指數答案大于Float.MAX_EXPONENT ,則返回無窮大。
These methods don't throw an exception.
這些方法不會引發異常。
These are static methods, it is accessible with the class name and, if we try to access these methods with the class object then we will not get any error.
這些是靜態方法,可以通過類名進行訪問,如果嘗試使用類對象訪問這些方法,則不會出現任何錯誤。
Parameter(s):
參數:
In the first case, scalb(double do , int sf) -
在第一種情況下, scalb(double do,int sf) -
- double do - This parameter represents the double number to be scaled by the power of 2.
- double do-此參數表示要以2的冪進行縮放的雙精度數。
- int sf - This argument represents integer type number power of 2 used to scale do.
- int sf-此參數表示用于定標do的整數類型的2的冪。
In the second case, scalb(float fl , int sf) -
在第二種情況下, scalb(float fl,int sf) -
- float fl - This argument represents the float type number to be scaled by the power of 2.
- float fl-此參數表示以2的冪進行縮放的float類型號。
- int sf - This argument represents integer number power of 2 used to scale fl.
- int sf-此參數表示2的整數次方,用于縮放fl。
Return value:
返回值:
In the first case, the return type of this method is double it returns the do* 2 raised to the power of sf.
在第一種情況下,此方法的返回類型為double,它會將do * 2提升為sf的冪。
In the second case, the return type of this method is float it returns the fl* 2 raised to the power of sf.
在第二種情況下,此方法的返回類型為float,它將返回提升為sf的fl * 2 。
Example:
例:
// Java program to demonstrate the example // of scalb () method of StrictMath classpublic class Scalb {public static void main(String[] args) {// variable declarationsfloat f1 = -0.0f;float f2 = -7.0f / 0.0f;float f3 = 20.0f;double d1 = -0.0;double d2 = -7.0 / 0.0;double d3 = 20.0;int i = 6;System.out.println("scalb(double do, int i): ");// Here , we will get (-0.0) because we are passing// parameter whose value is (-0.0f,6)System.out.println("StrictMath.scalb( f1,i): " + StrictMath.scalb(f1, i));// Here , we will get (-Infinity) and we are passing parameter // whose value is (-Infinity,6)System.out.println("StrictMath.scalb( f2,i): " + StrictMath.scalb(f2, i));// Here , we will get (20.0f * 2 raised to the power of 6) and// we are passing parameter whose value is (20.0f,6)System.out.println("StrictMath.scalb( f3,i): " + StrictMath.scalb(f3, i));System.out.println();System.out.println("scalb(double do, int i): ");// Here , we will get (-0.0) because we are passing // parameter whose value is (-0.0,6)System.out.println("StrictMath.scalb( d1,i): " + StrictMath.scalb(d1, i));// Here , we will get (-Infinity) and we are passing parameter // whose value is (-Infinity,6)System.out.println("StrictMath.scalb( d2,i): " + StrictMath.scalb(d2, i));// Here , we will get (20.0 * 2 raised to the power of 6.0) and// we are passing parameter whose value is (20.0,6)System.out.println("StrictMath.scalb( d3,i): " + StrictMath.scalb(d3, i));} }Output
輸出量
scalb(double do, int i): StrictMath.scalb( f1,i): -0.0 StrictMath.scalb( f2,i): -Infinity StrictMath.scalb( f3,i): 1280.0scalb(double do, int i): StrictMath.scalb( d1,i): -0.0 StrictMath.scalb( d2,i): -Infinity StrictMath.scalb( d3,i): 1280.0翻譯自: https://www.includehelp.com/java/strictmath-scalb-method-with-example.aspx
strictmath
總結
以上是生活随笔為你收集整理的strictmath_Java StrictMath scalb()方法与示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: tgc 什么意思 tgt_TGT的完整形
- 下一篇: java 枚举 示例_Java枚举nam