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

歡迎訪問 生活随笔!

生活随笔

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

java

ulp通信_Java Math类ulp()方法及示例

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

ulp通信

數學類ulp()方法 (Math class ulp() method)

  • ulp() method is available in java.lang package.

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

  • ulp() method is used to return the size of a ulp of the given argument, where, a ulp of the given value is the positive distance between floating-point value and the value next larger in magnitude.

    ulp()方法用于返回給定參數的ulp的大小,其中,給定值的ulp是浮點值與下一個幅度較大的值之間的正距離。

  • ulp() method is a static method, it is accessible with the class name too.

    ulp()方法是靜態方法,也可以使用類名進行訪問。

  • ulp() method does not throw any exception.

    ulp()方法不會引發任何異常。

Syntax:

句法:

public static float ulp(float value);public static double ulp(double value);

Parameter(s):

參數:

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

    value –表示要返回其ulp的浮點/雙浮點值。

Return value:

返回值:

The return type of this method is float/double – it returns the size of a ulp.

此方法的返回類型為float / double-返回ulp的大小。

Note:

注意:

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

    如果我們傳遞“ NaN”,它將返回相同的值(即“ NaN”)。

  • If we pass an infinity (+ve or –ve), it returns the infinity.

    如果我們傳遞無窮大(+ ve或–ve),它將返回無窮大。

  • If we pass a zero (0 or -0), it returns the "Float.MIN_VALUE" / "Double.MIN_VALUE".

    如果我們傳遞零(0或-0),它將返回“ Float.MIN_VALUE” /“ Double.MIN_VALUE”。

  • If we pass "Float.MAX_VALUE", it returns the 2^104 and in the case of "Double.MAX_VALUE", it returns the 2^971.

    如果我們傳遞“ Float.MAX_VALUE”,則返回2 ^ 104;對于“ Double.MAX_VALUE”,則返回2 ^ 971。

Java程序演示ulp()方法的示例 (Java program to demonstrate example of ulp() method)

// Java program to demonstrate the example of // ulp(float fl) method of Math Classpublic class UlpFloatTypeMethod {public static void main(String[] args) {// declaring the variablesfloat f1 = 0.0f;float f2 = -0.0f;float f3 = 7.0f / 0.0f;float f4 = -7.0f / 0.0f;float f5 = 1285.45f;// Display the valuesSystem.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 (Float.MIN_VALUE) because // we are passing parameter (0.0)System.out.println("Math.ulp(f1): " + Math.ulp(f1));// Here , we will get (Float.MIN_VALUE) because // we are passing parameter (-0.0)System.out.println("Math.ulp(f2): " + Math.ulp(f2));// Here , we will get (Infinity) because // we are passing parameter (7.0/0.0)System.out.println("Math.ulp(f3): " + Math.ulp(f3));// Here , we will get (Infinity) because // we are passing parameter (-7.0/0.0)System.out.println("Math.ulp(f4): " + Math.ulp(f4));// Here , we will get (2 raised to the power of 104) // because we are passing parameter (1285.45)System.out.println("Math.ulp(f5): " + Math.ulp(f5));} }

Output

輸出量

E:\Programs>javac UlpFloatTypeMethod.java E:\Programs>java UlpFloatTypeMethod f1: 0.0 f2: -0.0 f3: Infinity f4: -Infinity f5: 1285.45 Math.ulp(f1): 1.4E-45 Math.ulp(f2): 1.4E-45 Math.ulp(f3): Infinity Math.ulp(f4): Infinity Math.ulp(f5): 1.2207031E-4

Example 2:

范例2:

// Java program to demonstrate the example of // ulp(float fl) method of Math Classpublic class UlpFloatTypeMethod {public static void main(String[] args) {// declaring the variablesdouble d1 = 0.0;double d2 = -0.0;double d3 = 7.0 / 0.0;double d4 = -7.0f / 0.0;double d5 = 1285.45;// Display the valuesSystem.out.println("d1: " + d1);System.out.println("d2: " + d2);System.out.println("d3: " + d3);System.out.println("d4: " + d4);System.out.println("d5: " + d5);// Here , we will get (Float.MIN_VALUE) because // we are passing parameter (0.0)System.out.println("Math.ulp(d1): " + Math.ulp(d1));// Here , we will get (Float.MIN_VALUE) because // we are passing parameter (-0.0)System.out.println("Math.ulp(d2): " + Math.ulp(d2));// Here , we will get (Infinity) because // we are passing parameter (7.0/0.0)System.out.println("Math.ulp(d3): " + Math.ulp(d3));// Here , we will get (Infinity) because // we are passing parameter (-7.0/0.0)System.out.println("Math.ulp(d4): " + Math.ulp(d4));// Here , we will get (2 raised to the power of 971) // because we are passing parameter (1285.45)System.out.println("Math.ulp(d5): " + Math.ulp(d5));} }

Output

輸出量

E:\Programs>javac UlpMethod.java E:\Programs>java UlpMethod d1: 0.0 d2: -0.0 d3: Infinity d4: -Infinity d5: 1285.45 Math.ulp(d1): 4.9E-324 Math.ulp(d2): 4.9E-324 Math.ulp(d3): Infinity Math.ulp(d4): Infinity Math.ulp(d5): 2.2737367544323206E-13

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

ulp通信

總結

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

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