Java Float類floatToIntBits()方法與示例

Float類floatToIntBits()方法 (Float class floatToIntBits() method)

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

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

  • floatToIntBits() method follows IEEE 754 floating-point standards and according to standards, it returns the bits representation that denotes floating-point value.

    floatToIntBits()方法遵循IEEE 754浮點標準,并且根據標準,它返回表示浮點值的位表示形式。

  • floatToIntBits() method is a static method, it is accessible with the class name too and if we try to access the method with the class object then also we will not get an error.

    floatToIntBits()方法是一個靜態方法,也可以使用類名進行訪問,如果嘗試使用類對象訪問該方法,那么也不會收到錯誤。

  • floatToIntBits() method does not throw an exception at the time of representing bits.

    floatToIntBits()方法在表示位時不會引發異常。

Syntax:

句法:

    public static int floatToIntBits(float f);

Parameter(s):

參數:

  • float f – represents the single precision floating point value.

    float f –表示單精度浮點值。

Return value:

返回值:

The return type of this method is float, it returns the bits that represent the single precision floating-point value.

此方法的返回類型為float ,它返回表示單個精度浮點值的位。

  • If we pass "positive infinity", it returns the value "0x7f800000".

    如果我們傳遞“ positive infinity” ,它將返回值“ 0x7f800000”

  • If we pass "negative infinity", it returns the value "0xff800000".

    如果我們傳遞“負無窮大” ,它將返回值“ 0xff800000”

  • If we pass "NaN", it returns the value "0x7fc00000".

    如果我們傳遞“ NaN” ,它將返回值“ 0x7fc00000”

Example:

例:

// Java program to demonstrate the example 
// of floatToIntBits (float value)
// method of Float class
public class FloatToIntBitsOfFloatClass {
public static void main(String[] args) {
// Variables initialization
float value1 = 18.20f;
float value2 = 19.20f;
// Display value1,value2 values
System.out.println("value1: " + value1);
System.out.println("value2: " + value2);
// It returns the bits denoted by the single 
// precision floating-point argument by calling 
// Float.floatToIntBits(value1)
int result1 = Float.floatToIntBits(value1);
// It returns the bits denoted by the single 
// precision floating-point argument by calling 
// Float.floatToIntBits(value2)
int result2 = Float.floatToIntBits(value2);
// Display result1,result2 values
System.out.println("Float.floatToIntBits(value1): " + result1);
System.out.println("Float.floatToIntBits(value2): " + result2);
}
}

Output

輸出量

value1: 18.2
value2: 19.2
Float.floatToIntBits(value1): 1100061082
Float.floatToIntBits(value2): 1100585370

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

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

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

相關文章

解釋三度帶和六度帶的概念以及各坐標系如何定義

★ 地形圖坐標系:我國的地形圖采用高斯-克呂格平面直角坐標系。在該坐標系中,橫軸:赤道,用Y表示;縱軸:中央經線,用X表示;坐標原點:中央…

0-1背包問題(物品不可分割)

問題背景: 所謂“鐘點秘書”,是指年輕白領女性利用工余時間為客戶提供秘書服務,并按鐘點收取酬金。“鐘點秘書”為客戶提供有償服務的方式一般是:采用電話、電傳、上網等“遙控”式 服務,或親自到客戶公司處理部分業務…

算法---KMP算法

字符串1 KMP算法狀態機概述構建狀態轉移1 KMP算法 原文鏈接:https://zhuanlan.zhihu.com/p/83334559 先約定,本文用pat表示模式串,長度為M,txt表示文本串,長度為N,KMP算法是在txt中查找子串pat&#xff0…

cache初接觸,并利用了DataView

我們在寫代碼的時候,如果數據控件要獲得數據,一般方法,Conn.Open();OleDbCommand cmd;cmd new OleDbCommand(sql, Conn);GridView1.DataSource dbcenter.accessGetDataSet(sql);GridView1.DataBind();Conn.close();但如果多個數據控件要綁定數據,則比較頻繁打開數據庫,效率一…

Java ByteArrayInputStream reset()方法及示例

ByteArrayInputStream類reset()方法 (ByteArrayInputStream Class reset() method) reset() method is available in java.util package. reset()方法在java.util包中可用。 reset() method is used to reset this ByteArrayInputStream to the last time marked position and …

回文數猜想

問題描述: 一個正整數,如果從左向右讀(稱之為正序數)和從右向左讀(稱之為倒序數)是一樣的,這樣的數就叫回文數。任取一個正整數,如果不是回文數,將該數與他的倒序數相加…

文件上傳 帶進度條(多種風格)

文件上傳 帶進度條 多種風格 非常漂亮&#xff01; 友好的提示 以及上傳驗證&#xff01; 部分代碼&#xff1a; <form id"form1" runat"server"><asp:ScriptManager ID"scriptManager" runat"server" EnablePageMethods&quo…

同步---自旋鎖

1 自旋鎖的基本概念 自旋鎖最多只能被一個可執行線程持有&#xff0c;如果一個執行線程試圖獲得一個已經被使用的自旋鎖&#xff0c;那么該線程就會一直進行自旋&#xff0c;等待鎖重新可用。在任何時刻&#xff0c;自旋鎖都可以防止多余一個的執行線程同時進入臨界區。 Linu…

實習日志----4.播放時段參數設置

由于客戶在下發廣告時&#xff0c;一則廣告可在多個時段播放&#xff0c;這就需要設置多個播放時段的參數。 但在這種情況下&#xff0c;我并不知道用戶每次需要下發幾個時段&#xff0c;所以前臺不能設定死。 因此我要實現這么一個功能&#xff0c;讓用戶根據自己的需要來動態…

線性插值算法實現圖像_C程序實現插值搜索算法

線性插值算法實現圖像Problem: 問題&#xff1a; We are given an array arr[] with n elements and an element x to be searched amongst the elements of the array. 給定一個數組arr []&#xff0c;其中包含n個元素和一個要在該數組的元素中搜索的元素x 。 Solution: 解&…

hdu 1197

地址&#xff1a;http://acm.hdu.edu.cn/showproblem.php?pid1197 題意&#xff1a;求一個數轉換成10&#xff0c;12&#xff0c;16進制后各個位上的數的和是否相等。 mark&#xff1a;模擬進制轉換。 代碼&#xff1a; #include <stdio.h>int zh(int a, int n) {int su…

linux系統編程---線程總結

線程總結1 線程的實現線程創建線程退出線程等待線程清理2 線程的屬性線程的分離線程的棧地址線程棧大小線程的調度策略線程優先級3 線程的同步互斥鎖讀寫鎖條件變量信號量線程是系統獨立調度和分配的基本單位。同一進程中的多個線程將共享該進程中的全部系統資源&#xff0c;例…

博客上一些項目相關源碼鏈接

GitHub&#xff1a;https://github.com/beyondyanyu/Sayingyy

重新開啟Ctrl+Alt+Backspace快捷鍵

UBUNTU老用戶知道CtrlAltBackspace這個快捷鍵是用來快速重啟X的在9.04中被默認關閉了&#xff0c;那如何來打開它呢&#xff1f;在終端中輸入&#xff1a;sudo gedit /etc/X11/xorg.conf在其中加入&#xff1a;Section “ServerFlags”Option “DontZap” “false”EndSection退…

Java LocalDate類| 帶示例的getDayOfYear()方法

LocalDate類的getDayOfYear()方法 (LocalDate Class getDayOfYear() method) getDayOfYear() method is available in java.time package. getDayOfYear()方法在java.time包中可用。 getDayOfYear() method is used to get the day-of-year field value of this LocalDate obje…

火腿三明治定理

定理&#xff1a;任意給定一個火腿三明治&#xff0c;總有一刀能把它切開&#xff0c;使得火腿、奶酪和面包片恰好都被分成兩等份。 而且更有趣的是&#xff0c;這個定理的名字真的就叫做“火腿三明治定理”&#xff08;ham sandwich theorem&#xff09;。它是由數學家亞瑟?斯…

如何給Linux操作系統(CentOS 7為例)云服務器配置環境等一系列東西

1.首先&#xff0c;你得去購買一個云服務器&#xff08;這里以阿里云學生服務器為例&#xff0c;學生必須實名認證&#xff09; 打開阿里云&#xff0c;搜索學生服務器點擊進入即可 公網ip為連接云服務器的主機 自定義密碼為連接云服務器是需要輸入的密碼 購買即可 點擊云服…

Linux系統編程---I/O多路復用

文章目錄1 什么是IO多路復用2 解決什么問題說在前面I/O模型阻塞I/O非阻塞I/OIO多路復用信號驅動IO異步IO3 目前有哪些IO多路復用的方案解決方案總覽常見軟件的IO多路復用方案4 具體怎么用selectpollepolllevel-triggered and edge-triggered狀態變化通知(edge-triggered)模式下…

[轉帖]純屬娛樂——變形金剛vs天網

[轉帖]變形金剛2的影評-《變形金剛3 天網反擊戰》有一個問題困擾了我足足二十年&#xff1a;為什么汽車人要幫地球人&#xff1f;光用“所有有感知的生物都應享有自由”這個法則是根本說不過去的&#xff0c;因為豬也有感知&#xff0c;但人類就把豬圈養起來&#xff0c;隨意殺…

c#中textbox屬性_C#.Net中的TextBox.MaxLength屬性與示例

c#中textbox屬性Here we are demonstrating use of MaxLength property of TextBox. 在這里&#xff0c;我們演示了TextBox的MaxLength屬性的使用。 MaxLength property of TextBox is used to set maximum number of character that we can input into a TextBox. Limit of M…