博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
float_Keyword
阅读量:3926 次
发布时间:2019-05-23

本文共 1387 字,大约阅读时间需要 4 分钟。

float Java Keyword with Examples

The float keyword is used to declare float primitive variable. A float variable may store a single−precision floating point value. The type float specifies a single-precision value that uses 32 bits of storage. Single precision is faster on some processors and takes half as much space as double precision, but will become imprecise when the values are either very large or very small.

The Float wrapper class is used to represent float primitive variable as an object in Java.

float Java Keyword Examples
Syntax

float 
=
;

Example:

float price = 19.95;

The float keyword can be used to the declared return type of a method as well.

public float getBalance() {    return balanceAmount;}

The Java wrapper class associated with the float data type is called Float that is defined in java.lang package i.e. java.lang.Float.

float f = 65.55;
Float fRef = f;
Remarks

The following rules apply to float keyword’s use:

  • Floating point literals in Java always default to double−precision. To specify a single−precision literal value, follow the number with f or F, as in 0.01f.
  • In Java, float keyword is used to store the 32 bit float primitive types.
  • Java floating point numbers can represent infinity and NaN (not a number). The Float wrapper class defines the constants MIN_VALUE, MAX_VALUE, NEGATIVE_INFINITY, POSITIVE_INFINITY and NaN.

转载地址:http://sbgrn.baihongyu.com/

你可能感兴趣的文章
Flash 生命终止,HTML5能否完美替代?
查看>>
ML.NET生成器带来了许多错误修复和增强功能以及新功能
查看>>
微信适配国产操作系统:原生支持 Linux
查看>>
我的2020年终总结:新的角色,新的开始
查看>>
C# 9 新特性 —— 增强的模式匹配
查看>>
ASP.NET Core Controller与IOC的羁绊
查看>>
如何实现 ASP.NET Core WebApi 的版本化
查看>>
探索 .Net Core 的 SourceLink
查看>>
AgileConfig-如何使用AgileConfig.Client读取配置
查看>>
【gRPC】 在.Net core中使用gRPC
查看>>
整合.NET WebAPI和 Vuejs——在.NET单体应用中使用 Vuejs 和 ElementUI
查看>>
“既然计划没有变化快,那制订计划还有个卵用啊!”
查看>>
C#实现网页加载后将页面截取成长图片
查看>>
C# 在自定义的控制台输出重定向类中整合调用方信息
查看>>
C# 9 新特性 —— 补充篇
查看>>
Asp.Net Core使用Skywalking实现分布式链路追踪
查看>>
浅谈CLR基础知识
查看>>
Xamarin使XRPC实现接口/委托远程调用
查看>>
如何成功搞垮一个团队?
查看>>
.NET开源5年了,这些宝藏你还没get?
查看>>