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 class
public class Ulp {
public static void main(String[] args) {
// variable declarations
double 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 d5
System.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 d5
System.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

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/378087.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/378087.shtml
英文地址,請注明出處:http://en.pswp.cn/news/378087.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

八、非規則組織分析及其數學模型——平紋變化組織

非規則組織顧名思義,無法通過一個數學模型來描述所有的非規則組織、對于每一個具體的非規則組織而言,其也有一定的規律性可循,即可通過分析每一個具體的非規則組織的組織點運動規律來建立相應的數學模型。 一、平紋變化組織 平紋變化組織即…

怎么看xp計算機是32位還是64位,教你查看XP系統的不同32位還是64位詳細的步驟

電腦中使用的不同的版本如果安裝一些大型的游戲的時候都是有技巧來實現的,那在XP電腦中想要知道的對于不同的32位還是64位的版本的文件操作的時候新手是怎么知道自己安裝的軟件的版本呢,今天小編就來跟大家分享一下教你查看XP系統的不同32位還是64位詳細…

微軟面試100題2010年版全部答案集錦(含下載地址)

微軟等數據結構算法面試100題全部答案集錦作者:July、阿財。時間:二零一一年十月十三日。引言無私分享造就開源的輝煌。今是二零一一年十月十三日,明日14日即是本人剛好開博一周年。在一周年之際,特此分享出微軟面試全部100題答案…

get post

1. get是從服務器上獲取數據,post是向服務器傳送數據。2. get是把參數數據隊列加到提交表單的ACTION屬性所指的URL中,值和表單內各個字段一一對應,在URL中可以看到。post是通過HTTP post機制,將表單內各個字段與其內容放置在HTML …

LeetCode 27.移除元素 思考分析

題目 給你一個數組 nums 和一個值 val,你需要 原地 移除所有數值等于 val 的元素,并返回移除后數組的新長度。 不要使用額外的數組空間,你必須僅使用 O(1) 額外空間并 原地 修改輸入數組。 元素的順序可以改變。你不需要考慮數組中超出新長…

九、非規則組織分析及其數學模型——曲線斜紋組織

曲線斜紋組織圖: 因為其形狀酷似拋物線,拋物線又是曲線中的一種,故稱為曲線斜紋組織。 特點:1,每一根經紗上的組織點運動規律不變 2,飛數是變化的,故也稱為變飛數組織 飛數滿足的兩個條件&…

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…

計算機公式column,函數公式的左膀右臂:ROW、COLUMN函數知多少

一個公式生成乘法口訣表演示的公式中用到了兩個函數:ROW和COLUMN,這兩個函數的用途非常廣泛,可以配合其他函數實現很多功能(尤其是和VLOOKUP函數),另外和這兩個函數相似的還有ROWS和COLUMNS函數,也順便介紹下。函數說明…

apache2.4.x三種MPM介紹

三種MPM介紹 Apache 2.X 支持插入式并行處理模塊,稱為多路處理模塊(MPM)。在編譯apache時必須選擇也只能選擇一個MPM,對類UNIX系統,…

LeetCode 15. 三數之和 思考分析(雙指針解)

目錄初解:未考慮去重二解:未考慮去重位置三解:AC題目:給你一個包含 n 個整數的數組 nums,判斷 nums 中是否存在三個元素 a,b,c ,使得 a b c 0 ?請你找出所有滿足條件且…

十、非規則組織分析及其數學模型——鋸齒形斜紋組織

鋸齒形斜紋組織圖: 分析: 前半齒長度k,表示山谷到山峰的列數,也就是鋸齒的寬度; 鋸齒飛數s,表示山峰到山峰的行數,也就是鋸齒的高度。 起始點相差4格,也就是第一部分整體向上移動…

Linq lamdba GroupJoin外連接示例

其實用from..Linq語句做外連接簡單而且便于理解&#xff0c;我個人使用lamdba純粹是技術上的追求吧 DataTable exceldtnew DataTable();DataTable nomacdtnew DataTable();exceldt exceldt.AsEnumerable().GroupJoin(nomacdt.AsEnumerable(), a > a.Field<String>(&q…

ajax為什么有時候不行,為什么不能用ajax調用

Ajax取值時出現未知的運行時錯誤的解決方法在Ajax里經常會通過innerHTML來改變界面&#xff0c;這個比使用DOM要簡單一些。比如&#xff1a;element.innerHTML "put code here"不過&#xff0c;在IE中&#xff0c;有時候會出現"未知的運行時錯誤(unknown runti…

Java Hashtable size()方法與示例

哈希表類size()方法 (Hashtable Class size() method) size() method is available in java.util package. size()方法在java.util包中可用。 size() method is used to return the number of key-value pairs that exist in this Hashtable. size()方法用于返回此哈希表中存在…

十一、非規則組織分析及其數學模型——蘆席斜紋組織

蘆席斜紋組織&#xff1a; 該組織是由左斜和右斜有機的結合在一塊的&#xff0c;因為其外觀酷似蘆席故稱之為蘆席斜紋組織。 織物組織效果&#xff1a; 所需參數&#xff1a; 其基層組織采用雙面加強型斜紋&#xff0c;即分子和分母是相同的組織點&#xff0c;例如2上2下(2個經…

LeetCode 18. 四數之和 思考分析(雙指針解)

目錄需要注意的幾點1、去除剪枝操作2、去重操作的細節code以及效果&#xff1a;題目給定一個包含 n 個整數的數組 nums 和一個目標值 target&#xff0c;判斷 nums 中是否存在四個元素 a&#xff0c;b&#xff0c;c 和 d &#xff0c;使得 a b c d 的值與 target 相等&#…

圖解DotNet框架之一:編譯與執行引擎(上)

眾所周知,DotNet框架是非常龐大的,光項目創建時的種類就有WPF,WCF,WF這三種最新的技術,還有以前的Web,WinForm,Service,Mobile等等. 這么復雜和龐大的框架,用文字來描述是遠遠不夠的,所以我準備寫一系列圖文并茂的文章,把我所知道的所有Net框架中的東西全部串聯起來,希望可以給…

【Kissy WaterFall】實行手動加載數據

前言&#xff1a;由于Kissy WaterFall默認是監聽滾動事件來實現數據動態加載的&#xff0c;但是有一些情況要用到手動加載數據。以下是使用Kissy WaterFall實現手動加載數據的方法。 最終實現效果&#xff1a;點擊”逛更多的商店“會動態加載數據 步驟&#xff1a; 當一頁數據加…

web服務器文檔根目錄在哪里,web服務器根目錄在哪

web服務器根目錄在哪 內容精選換一換SSL證書通過在客戶端瀏覽器和Web服務器之間建立一條SSL安全通道(訪問方式為HTTPS)&#xff0c;實現數據信息在客戶端和服務器之間的加密傳輸&#xff0c;可以防止數據信息的泄露。SSL保證了雙方傳遞信息的安全性&#xff0c;而且用戶可以通過…

console java_Java Console writer()方法與示例

console java控制臺類writer()方法 (Console Class writer() method) writer() method is available in java.io package. writer()方法在java.io包中可用。 writer() method is used to get a distinct PrintWriter object linked with this Console. writer()方法用于獲取與此…