日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

strictmath_Java StrictMath ulp()方法与示例

發布時間:2023/12/1 java 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 strictmath_Java StrictMath ulp()方法与示例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

strictmath

StrictMath類ulp()方法 (StrictMath Class ulp() method)

Syntax:

句法:

public static double ulp(double do);public static float ulp(float fl);
  • ulp() Method is available in java.lang package.

    ulp()方法在java.lang包中可用。

  • ulp(double do) Method is used to return the size of an ulp of the given argument in the method. In this method, an ulp of the given double value parameter is the positive distance between double floating-point value and the given argument double value next larger in magnitude.

    ulp(double do)方法用于返回方法中給定參數的ulp的大小。 在此方法中,給定雙值參數的ulp是雙浮點值與下一個幅度較大的給定自變量double值之間的正距離。

  • ulp(float fl) Method is used to return the size of an ulp of the given argument in the method. In this method, an ulp of the given float value parameter is the positive distance between float floating-point value and the given argument float value next larger in magnitude.

    ulp(float fl)方法用于返回方法中給定參數的ulp的大小。 在此方法中,給定浮點值參數的ulp是浮點浮點值與給定自變量浮點值之間的正距離,其大小隨后更大。

  • 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):

參數:

  • float / double – represents the value represents the double floating point value whose ulp is to be returned.

    float / double-表示該值表示要返回其ulp的double浮點值。

Return value:

返回值:

The return type of the method is float / double, it returns the size of an ulp of the given parameter and return value is of float / double type.

該方法的返回類型為float / double ,它返回給定參數的ulp的大小,返回值為float / double類型。

Note:

注意:

  • If we pass NaN, the method returns the same value (i.e. NaN).

    如果我們通過NaN,則該方法返回相同的值(即NaN)。

  • If we pass an infinity (positive or negative), the method returns the positive infinity.

    如果我們傳遞無窮大(正數或負數),則該方法將返回正無窮大。

  • If we pass zero (positive or negative), the method returns the Float.MIN_VALUE / Double.MIN_VALUE.

    如果傳遞零(正數或負數),則該方法返回Float.MIN_VALUE / Double.MIN_VALUE 。

  • If we pass Float.MAX_VALUE, the method returns the 2 raised to the power of 104 and if we pass Double.MAX_VALUE, the method returns the 2 raised to the power of 971.

    如果傳遞Float.MAX_VALUE ,則該方法返回2的冪,以104的冪表示;如果傳遞Double.MAX_VALUE ,則該方法返回2的冪為971的冪。

Example:

例:

// Java program to demonstrate the example // of signum() method of StrictMath classpublic class Ulp {public static void main(String[] args) {// variable declarationsdouble d1 = 0.0;double d2 = -0.0;double d3 = 7.0 / 0.0;double d4 = -7.0 / 0.0;double d5 = 1285.45;float f1 = 0.0f;float f2 = -0.0f;float f3 = 7.0f / 0.0f;float f4 = -7.0f / 0.0f;float f5 = 1285.45f;System.out.println();System.out.println("ulp(double d:)");// Display previous value of d1,d2,d3 ,d4and d5System.out.println("d1:" + d1);System.out.println("d2: " + d2);System.out.println("d3: " + d3);System.out.println("d4: " + d4);System.out.println("d5: " + d5);// Display previous value of f1,f2,f3 ,f4and d5System.out.println("f1: " + f1);System.out.println("f2: " + f2);System.out.println("f3: " + f3);System.out.println("f4: " + f4);System.out.println("f5: " + f5);// Here , we will get (Double.MIN_VALUE) because// we are passing parameter (0.0)System.out.println("StrictMath.ulp(d1): " + StrictMath.ulp(d1));// Here , we will get (Double.MIN_VALUE) because// we are passing parameter (-0.0) System.out.println("StrictMath.ulp(d2): " + StrictMath.ulp(d2));// Here , we will get (Infinity) because// we are passing parameter (7.0/0.0) System.out.println("StrictMath.ulp(d2): " + StrictMath.ulp(d3));// Here , we will get (Infinity) because // we are passing parameter (-7.0/0.0)System.out.println("StrictMath.ulp(d2): " + StrictMath.ulp(d4));// Here , we will get (2 raised to the power of 971) because// we are passing parameter (1285.45)System.out.println("StrictMath.ulp(d5): " + StrictMath.ulp(d5));System.out.println();System.out.println("ulp(float fl:)");// Here , we will get (Float.MIN_VALUE) because // we are passing parameter (0.0)System.out.println("StrictMath.ulp(f1): " + StrictMath.ulp(f1));// Here , we will get (Float.MIN_VALUE) because // we are passing parameter (-0.0) System.out.println("StrictMath.ulp(f2): " + StrictMath.ulp(f2));// Here , we will get (Infinity) because // we are passing parameter (7.0/0.0) System.out.println("StrictMath.ulp(f3): " + StrictMath.ulp(f3));// Here , we will get (Infinity) because // we are passing parameter (-7.0/0.0) System.out.println("StrictMath.ulp(f4): " + StrictMath.ulp(f4));// Here , we will get (2 raised to the power of 971) because// we are passing parameter (1285.45) System.out.println("StrictMath.ulp(f5): " + StrictMath.ulp(f5));} }

Output

輸出量

ulp(double d:) d1:0.0 d2: -0.0 d3: Infinity d4: -Infinity d5: 1285.45 f1: 0.0 f2: -0.0 f3: Infinity f4: -Infinity f5: 1285.45 StrictMath.ulp(d1): 4.9E-324 StrictMath.ulp(d2): 4.9E-324 StrictMath.ulp(d2): Infinity StrictMath.ulp(d2): Infinity StrictMath.ulp(d5): 2.2737367544323206E-13ulp(float fl:) StrictMath.ulp(f1): 1.4E-45 StrictMath.ulp(f2): 1.4E-45 StrictMath.ulp(f3): Infinity StrictMath.ulp(f4): Infinity StrictMath.ulp(f5): 1.2207031E-4

翻譯自: https://www.includehelp.com/java/strictmath-ulp-method-with-example.aspx

strictmath

總結

以上是生活随笔為你收集整理的strictmath_Java StrictMath ulp()方法与示例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。