Java BigDecimal intValue()方法与示例

BigDecimal类的intValue()方法 (BigDecimal Class intValue() method)

  • intValue() method is available in java.math package.

    intValue()方法在java.math包中可用。

  • intValue() method is used to convert a BigDecimal to an integer and when the converted BigDecimal value is large enough to fit into an integer then in that case low order 32 bits are to be retrieved and the returned value is with opposite sign.

    intValue()方法用于将BigDecimal转换为整数,并且当转换的BigDecimal值足够大以适合整数时,在这种情况下,将检索低阶32位,并且返回的值带有相反的符号。

  • intValue() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    intValue()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。

  • intValue() method does not throw an exception at the time of converting BigDecimal to int.

    在将BigDecimal转换为int时, intValue()方法不会引发异常。

Syntax:

句法:

    public int intValue();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of this method is int, it gets the integer representation of this BigDecimal.

此方法的返回类型为int ,它获取此BigDecimal的整数表示形式。

Example:

例:

// Java program to demonstrate the example 
// of int intValue() method of BigDecimal
import java.math.*;
public class IntValueOfBD {
public static void main(String args[]) {
// Initialize two variables first is
// of "double" and second is of "String"
// type
double val = 115.23;
String str = "100";
// Initialize two BigDecimal objects  
BigDecimal b_dec1 = new BigDecimal(val);
BigDecimal b_dec2 = new BigDecimal(str);
// convert this BigDecimal (b_dec1) into
// an int, variable named i_conv
int i_conv = b_dec1.intValue();
System.out.println("b_dec1.intValue(): " + i_conv);
// convert this BigDecimal (b_dec2) into
// an int, variable named i_conv
i_conv = b_dec2.intValue();
System.out.println("b_dec2.intValue(): " + i_conv);
}
}

Output

输出量

b_dec1.intValue(): 115
b_dec2.intValue(): 100

翻译自: https://www.includehelp.com/java/bigdecimal-intvalue-method-with-example.aspx

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/541486.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

R语言数据挖掘

数据分析与决策技术丛书 R语言数据挖掘 Learning Data Mining with R [哈萨克斯坦]贝特麦克哈贝尔(Bater Makhabel) 著 李洪成 许金炜 段力辉 译 图书在版编目(CIP)数据 R语言数据挖掘 / (哈…

linux adduser mysql_linux_adduser

新帐号建立当不加-D参数,useradd指令使用命令列来指定新帐号的设定值and使用系统上的预设值.新使用者帐号将产生一些系统档案,使用者目录建立,拷备起始档案等,这些均可以利用命令列选项指定。此版本为RedHatLinux提供,可帮每个新加…

java iterator_Java ArrayDeque iterator()方法与示例

java iteratorArrayDeque类iterator()方法 (ArrayDeque Class iterator() method) iterator() Method is available in java.lang package. iterator()方法在java.lang包中可用。 iterator() Method is used to return an iterator over the deque elements. iterator()方法用于…

《jQuery、jQuery UI及jQuery Mobile技巧与示例》——7.4 示例:使用按钮集装饰单选框...

本节书摘来自异步社区《jQuery、jQuery UI及jQuery Mobile技巧与示例》一书中的第7章,第7.4节,作者:【荷】Adriaan de Jonge , 【美】Phil Dutson著,更多章节内容可以访问云栖社区“异步社区”公众号查看 7.4 示例:使…

mysql 模拟序列_【原创】MySQL 模拟PostgreSQL generate_series 表函数

PostgreSQL 提供了一个很强大的造数据的函数generate_series,基于Common Table Expression。MySQL 没有复杂的应用程序类型,该如何实现这样的功能呢? 我想到的三种方法如下:1. 用存储过程来做。 缺点是写好多数据库不擅长的应用逻辑。2. 我们…

Python字符串| isdigit()方法与示例

isdigit() is an in-built method in Python, which is used to check whether a string contains only digits or not. isdigit()是Python中的内置方法,用于检查字符串是否仅包含数字。 Digit value contains all decimal characters and other digits which may …

vue2.0的学习

vue-router 除了使用 <router-link> 创建 a 标签来定义导航链接&#xff0c;我们还可以借助 router 的实例方法&#xff0c;通过编写代码来实现。 1&#xff09;router.push(location) 这个方法会向 history 栈添加一个新的记录&#xff0c;所以&#xff0c;当用户点击浏…

mysql+url的配置参数详解_MySql链接url参数详解

mysql URL格式如下&#xff1a;jdbc:mysql://[host:port],[host:port].../[database][?参数名1][参数值1][&参数名2][参数值2]...MySQL在高版本需要指明是否进行SSL连接 在url后面加上 useSSLtrue 不然写程序会有warning常用的几个较为重要的参数&#xff1a;参数名…

Java LocalDate类| minus()方法与示例

LocalDate类isSupported()方法 (LocalDate Class isSupported() method) Syntax: 句法&#xff1a; public LocalDate minus(TemporalAmount t_amt);public LocalDate minus(long amt, TemporalUnit t_unit);isSupported() method is available in java.time package. isSuppo…

《Java EE 7精粹》—— 第3章 JSF 3.1 Facelets

本节书摘来异步社区《Java EE 7精粹》一书中的第2章&#xff0c;第2.1节&#xff0c;作者&#xff1a;【美】Arun Gupta&#xff0c;更多章节内容可以访问云栖社区“异步社区”公众号查看。 第3章 JSF JSF是基于Java的Web应用程序开发的服务器端用户界面&#xff08;UI&#xf…

mysql5批处理_转关于mysql5.5 的批处理讨论(转载)

MySql的JDBC驱动不支持批量操作(已结)MySql连接的url中要加rewriteBatchedStatements参数&#xff0c;例如String connectionUrl"jdbc:mysql://192.168.1.100:3306/test?rewriteBatchedStatementstrue";还要保证mysql JDBC驱的版本。MySql的JDBC驱动的批量插入操作性…

Java Duration类| isZero()方法与示例

持续时间类isZero()方法 (Duration Class isZero() method) isZero() method is available in java.time package. isZero()方法在java.time包中可用。 isZero() method is used to check whether this Duration object holds the value of length is 0 or not. isZero()方法用…

《C#多线程编程实战(原书第2版)》——3.2 在线程池中调用委托

本节书摘来自华章出版社《C#多线程编程实战&#xff08;原书第2版&#xff09;》一书中的第3章&#xff0c;第3.2节&#xff0c;作者&#xff08;美&#xff09;易格恩阿格佛温&#xff08;Eugene Agafonov&#xff09;&#xff0c;黄博文 黄辉兰 译&#xff0c;更多章节内容可…

mysql语句数据库_数据库的Mysql语句

数据库的mysql语句: 1.连接数据库 mysql -u root -p2.显示数据库 show databases(db);3.选择数据库 use 数据库名;4.显示数据库中的表 show tables;基本数据操作:增删改查1.增 :insert into 表名(字段1,字段2…)values (值1,值2…);2.删 :delete from 表名 where 条件;3.改 :up…

java clock计时_Java Clock类| systemUTC()方法与示例

java clock计时Clock Class systemUTC()方法 (Clock Class systemUTC() method) systemUTC() method is available in java.time package. systemUTC()方法在java.time包中可用。 systemUTC() method is used to get a Clock that implements the suitable system clock in the…

《Android 应用测试指南》——第2章,第2.4节包浏览器

本节书摘来自异步社区《Android 应用测试指南》一书中的第2章&#xff0c;第2.4节包浏览器&#xff0c;作者 【阿根廷】Diego Torres Milano&#xff08;迭戈 D.&#xff09;&#xff0c;更多章节内容可以访问云栖社区“异步社区”公众号查看 2.4 包浏览器创建完前面提到的两个…

操作系统系统调用_操作系统中的系统调用

操作系统系统调用系统调用简介 (Introduction to System calls) The interface between the operating system and the user program is defined by the set of extended instruction that the operating system provides. These extended instructions are known as system ca…

java分数表示_表示Java分数的最佳方法?

小编典典碰巧的是不久前我写了一个BigFraction类&#xff0c;用于解决Euler项目问题。它保留了BigInteger分子和分母&#xff0c;因此它将永远不会溢出。但是&#xff0c;对于许多你永远不会溢出的操作来说&#xff0c;这会有点慢。无论如何&#xff0c;请根据需要使用它。我一…

《OpenStack云计算实战手册(第2版)》——1.7 添加用户

本节书摘来自异步社区《OpenStack云计算实战手册&#xff08;第2版&#xff09;》一书中的第1章&#xff0c;第1.7节,作者&#xff1a; 【英】Kevin Jackson , 【美】Cody Bunch 更多章节内容可以访问云栖社区“异步社区”公众号查看。 1.7 添加用户 在OpenStack身份认证服务中…

开源软件和自由软件_自由和开源软件的经济学

开源软件和自由软件零边际成本 (Zero Marginal Cost) At the core of the financial aspects of Free and Open Source is the zero negligible expense of merchandise in an environment that is digital. Right now, the rise of Free and Open Source speaks to an affirma…