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.mzph.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…