strictmath_Java StrictMath scalb()方法与示例

strictmath

StrictMath类scalb()方法 (StrictMath Class scalb() method)

Syntax:

句法:

    public static double scalb(double do , int sf);
public static float scalb(float fl , int sf);

  • scalb(double do , int sf) method is used to return do* 2 raised to the power of sf rounded as an argument as passed in the method.

    scalb(double do,int sf)方法用于将do * 2提升为sf的幂,该整数作为方法中传递的参数进行舍入。

  • scalb(double do , int sf)

    scalb(double do,int sf)

    • If the exponent lies in between Double.MIN_EXPONENT and Double.MAX_EXPONENT and in that case the result is exactly calculated.
    • 如果指数位于Double.MIN_EXPONENT和Double.MAX_EXPONENT之间,则在这种情况下,将精确计算结果。
    • If the exponent answer would be greater than Double.MAX_EXPONENT and in that case infinity is returned.
    • 如果指数答案大于Double.MAX_EXPONENT ,则返回无穷大。
    • scalb(float fl , int sf) method is used to return fl* 2 raised to the power of sf rounded as an argument as passed in the method.
    • scalb(float fl,int sf)方法用于返回fl * 2 ,该值被提升为sf的幂,该整数作为方法中传递的参数进行舍入。
  • scalb(float fl , int sf)

    scalb(float fl,int sf)

    • If the exponent lies in between Float.MIN_EXPONENT and Float.MAX_EXPONENT and in that case the result is exactly calculated.
    • 如果指数位于Float.MIN_EXPONENT和Float.MAX_EXPONENT之间, 那么在这种情况下,结果将被精确计算。
    • If the exponent answer would be greater than Float.MAX_EXPONENT and in that case infinity is returned.
    • 如果指数答案大于Float.MAX_EXPONENT ,则返回无穷大。
  • 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):

参数:

  • In the first case, scalb(double do , int sf) -

    在第一种情况下, scalb(double do,int sf) -

    • double do - This parameter represents the double number to be scaled by the power of 2.
    • double do-此参数表示要以2的幂进行缩放的双精度数。
    • int sf - This argument represents integer type number power of 2 used to scale do.
    • int sf-此参数表示用于定标do的整数类型的2的幂。
  • In the second case, scalb(float fl , int sf) -

    在第二种情况下, scalb(float fl,int sf) -

    • float fl - This argument represents the float type number to be scaled by the power of 2.
    • float fl-此参数表示以2的幂进行缩放的float类型号。
    • int sf - This argument represents integer number power of 2 used to scale fl.
    • int sf-此参数表示2的整数次方,用于缩放fl。

Return value:

返回值:

In the first case, the return type of this method is double it returns the do* 2 raised to the power of sf.

在第一种情况下,此方法的返回类型为double,它会将do * 2提升为sf的幂。

In the second case, the return type of this method is float it returns the fl* 2 raised to the power of sf.

在第二种情况下,此方法的返回类型为float,它将返回提升为sf的fl * 2 。

Example:

例:

// Java program to demonstrate the example 
// of scalb () method of StrictMath class
public class Scalb {
public static void main(String[] args) {
// variable declarations
float f1 = -0.0f;
float f2 = -7.0f / 0.0f;
float f3 = 20.0f;
double d1 = -0.0;
double d2 = -7.0 / 0.0;
double d3 = 20.0;
int i = 6;
System.out.println("scalb(double do, int i): ");
// Here , we will get (-0.0) because we are passing
// parameter whose value is (-0.0f,6)
System.out.println("StrictMath.scalb( f1,i): " + StrictMath.scalb(f1, i));
// Here , we will get (-Infinity) and we are passing parameter 
// whose value is (-Infinity,6)
System.out.println("StrictMath.scalb( f2,i): " + StrictMath.scalb(f2, i));
// Here , we will get (20.0f * 2 raised to the power of 6) and
// we are passing parameter whose value is (20.0f,6)
System.out.println("StrictMath.scalb( f3,i): " + StrictMath.scalb(f3, i));
System.out.println();
System.out.println("scalb(double do, int i): ");
// Here , we will get (-0.0) because we are passing 
// parameter whose value is (-0.0,6)
System.out.println("StrictMath.scalb( d1,i): " + StrictMath.scalb(d1, i));
// Here , we will get (-Infinity) and we are passing parameter 
// whose value is (-Infinity,6)
System.out.println("StrictMath.scalb( d2,i): " + StrictMath.scalb(d2, i));
// Here , we will get (20.0 * 2 raised to the power of 6.0) and
// we are passing parameter whose value is (20.0,6)
System.out.println("StrictMath.scalb( d3,i): " + StrictMath.scalb(d3, i));
}
}

Output

输出量

scalb(double do, int i): 
StrictMath.scalb( f1,i): -0.0
StrictMath.scalb( f2,i): -Infinity
StrictMath.scalb( f3,i): 1280.0scalb(double do, int i): 
StrictMath.scalb( d1,i): -0.0
StrictMath.scalb( d2,i): -Infinity
StrictMath.scalb( d3,i): 1280.0

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

strictmath

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

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

相关文章

你知道group by的工作原理和优化思路吗?

前言 日常开发中,我们经常会使用到group by。亲爱的小伙伴,你是否知道group by的工作原理呢?group by和having有什么区别呢?group by的优化思路是怎样的呢?使用group by有哪些需要注意的问题呢?本文将跟大家…

strictmath_Java StrictMath hypot()方法与示例

strictmathStrictMath类hypot()方法 (StrictMath Class hypot() method) hypot() method is available in java.lang package. hypot()方法在java.lang包中可用。 hypot() method is used to return the square root of sqrt(sq(d1)sq(d2)) without any intermediate operation…

关Jquery判断input type=checkbox元素是否被选中的判断

2019独角兽企业重金招聘Python工程师标准>>> 在用到复选框的时候&#xff0c;想在js中判断chekbox是否被选中 <input name"isPermit" id"isPermit" type"checkbox"> 百度了很多的判断方法 1、 if($("#isPermit").att…

Redis夺命十二问,你能扛到第几问?

Redis是面试中绕不过的槛&#xff0c;只要在简历中写了用过Redis&#xff0c;肯定逃不过。今天我们就来模拟一下面试官在Redis这个话题上是如何一步一步深入&#xff0c;全面考察候选人对于Redis的掌握情况。小张&#xff1a;面试官&#xff0c;你好。我是来参加面试的。面试官…

Java Scanner nextLine()方法与示例

扫描仪类nextLine()方法 (Scanner Class nextLine() method) nextLine() method is available in java.util package. nextLine()方法在java.util包中可用。 nextLine() method is used to get the skipped line. nextLine()方法用于获取跳过的行。 nextLine() method is a non…

bzoj 1192

http://www.lydsy.com/JudgeOnline/problem.php?id1192 好像学过一个东西&#xff1a; [0..2^(N1)-1]内的数都的都可以由2^0,2^1,...,2^N这N1个数中若干个相加得到。 #include<cstdio> #include<cstdlib> #include<iostream> #include<fstream> #incl…

Spring Boot Admin 报警提醒和登录验证功能实现!

作者 | 磊哥来源 | Java中文社群&#xff08;ID&#xff1a;javacn666&#xff09;转载请联系授权&#xff08;微信ID&#xff1a;GG_Stone&#xff09;Spring Boot Admin&#xff08;SBA&#xff09;是一个开源的社区项目&#xff0c;用于管理和监控 Spring Boot 应用程序&…

Java Hashtable rehash()方法与示例

哈希表类rehash()方法 (Hashtable Class rehash() method) rehash() method is available in java.util package. rehash()方法在java.util包中可用。 rehash() method is used to extend the capacity and it is invoked implicitly if the number of keys limit exceeds hash…

企业Shell面试题18:单词及字母去重排序案例

1、按单词出现频率降序排序&#xff01; 2、按字母出现频率降序排序&#xff01; the squid project provides a number of resources to assist users design,implement and support squid installations. Please browse the documentation and support sections for more inf…

5种高大上的yml读取方式,你知道几种?

我们今天就来点实战&#xff0c;总结一下除了烂大街的Value和ConfigurationProperties外&#xff0c;还有哪些读取yml配置文件的方法&#xff1f;1、Environment在Spring中有一个类Environment&#xff0c;它可以被认为是当前应用程序正在运行的环境&#xff0c;它继承了Proper…

Java Hashtable equals()方法与示例

哈希表类equals()方法 (Hashtable Class equals() method) equals() method is available in java.util package. equals()方法在java.util包中可用。 equals() method is used to check whether equality of this Hashtable with the given Object or not. equals()方法用于检…

为什么ConcurrentHashMap不允许插入null值?

作者&#xff1a;磊哥来源 | Java面试真题解析&#xff08;ID&#xff1a;aimianshi666&#xff09;转载请联系授权&#xff08;微信ID&#xff1a;GG_Stone&#xff09;在 Java 语言中&#xff0c;ConcurrentHashMap 和 Hashtable 这些线程安全的集合是不允许 key 或 value 插…

.NET APlayer播放器 demo

工作需要,想开发一款播放器,当无意间浏览到APlayer的时候大爱啊,有木有迅速投入精力,在APlayer论坛看大牛们的作品及经验,看SDK中提供的chm电子书最后看了博客园中周见智的文章(灰常好!最终作品也用的他的demo改进)先来晒一下最终的效果图片。 效果截图&#xff1a;1.初始界面。…

Java Formatter format()方法及示例

Formatter类format()方法 (Formatter Class format() method) Syntax: 句法&#xff1a; public Formatter format(Locale lo, String frmt, Object... args);public Formatter format(String frmt, Object... args);format() method is available in java.util package. form…

Spring Cloud Alibaba Nacos 服务注册与发现功能实现!

作者 | 磊哥来源 | Java中文社群&#xff08;ID&#xff1a;javacn666&#xff09;转载请联系授权&#xff08;微信ID&#xff1a;GG_Stone&#xff09;Nacos 是 Spring Cloud Alibaba 中一个重要的组成部分&#xff0c;它提供了两个重要的功能&#xff1a;服务注册与发现和统一…

Java类class cast()方法及示例

类class cast()方法 (Class class cast() method) cast() method is available in java.lang package. 在java.lang包中提供了cast()方法 。 cast() method casts this Object to the class or an interface denoted by this Class object. cast()方法将此Object强制转换为该Cl…

加分进了字节,MySQL真yyds!

Java研发工程师必备技能非MySQL莫属&#xff0c;虽说易学好上手&#xff0c;但应对大厂面试&#xff0c;最容易遭遇滑铁卢、功败垂成的也是它。上手简单&#xff0c;玩转难&#xff0c;才是这款开源数据库叱咤业界多年的真实写照。MySQL 8.0正式版的到来&#xff0c;在性能和速…

基于Fragment的百度地图框架的使用

博客:http://blog.csdn.net/developer_jiangqq (一)基本介绍(Fragment和SupportMapFragment): Fragment的使用现在安卓APP开发中用的比较多了&#xff0c;Fragment名称为碎片和Activity有着相似的生命管理周期&#xff0c;基本作用可以进行开发兼容手机和平板的app,较少兼容分辨…

Nacos服务注册与发现的2种实现方法!

作者 | 磊哥来源 | Java中文社群&#xff08;ID&#xff1a;javacn666&#xff09;转载请联系授权&#xff08;微信ID&#xff1a;GG_Stone&#xff09;Spring Cloud Alibaba 技术体系中的 Nacos&#xff0c;提供了两个重要的功能&#xff1a;注册中心&#xff08;服务注册与发…

java settime_Java日历setTime()方法及示例

java settime日历类setTime()方法 (Calendar Class setTime() method) setTime() method is available in java.util package. setTime()方法在java.util包中可用。 setTime() method is used to sets time with the specified Date(d) of this Calendar. setTime()方法用于使用…