根据基本几何形状,斜边仅是right-angled三角形的最长边。它是与三角形直角相反的一侧。为了找到right-angled三角形的斜边的长度,应用勾股定理。根据该定理,给定长度为p和b的三角形的两个垂直边,可以通过以下公式找到斜边

的Java.lang.StrictMath.hypot()是StrictMath类的一种内置方法,用于获取给定两侧或自变量的平方和的斜边或square-root。

。该方法排除了所有中间上溢和下溢。它不会产生一些特殊结果:

当num1或num2为无限时,该方法返回正无穷大。

当任何一个参数为NAN并且两个参数都不为无限时,它将返回NAN。

用法:

public static double hypot(double num1, double num2)

参数:该方法接受Double类型的两个参数:

num1:这是第一个值或任何一侧。

num2:这是第二个值或另一边。

返回值:方法返回

即斜边的长度。

例子:

Input: num1 = 3

num2 = 4

Output: 5.0

以下示例程序旨在说明Java.lang.StrictMath.hypot()方法:

示例1:

// Java praogram to illustrate the

// Java.lang.StrictMath.hypot() Method

import java.lang.*;

public class Geeks {

public static void main(String[] args)

{

double num1 = 11, num2 = 13.8;

// It returns the hypotenuse

double hypotlen = StrictMath.hypot(num1, num2);

System.out.println("Length of hypotenuse  of side "

+ num1 + " & " + num2 + " = " + hypotlen);

}

}

输出:

Length of hypotenuse of side 11.0 & 13.8 = 17.647662734764623

示例2:

// Java praogram to illustrate the

// Java.lang.StrictMath.hypot() Method

import java.lang.*;

public class Geeks {

public static void main(String[] args)

{

double num1 = -54, num2 = -24.8;

// It returns the hypotenuse

double hypotlen = StrictMath.hypot(num1, num2);

System.out.println("Length of hypotenuse  of side "

+ num1 + " & " + num2 + " = " + hypotlen);

}

}

输出:

Length of hypotenuse of side -54.0 & -24.8 = 59.422554640473

示例3:

// Java praogram to illustrate the

// Java.lang.StrictMath.hypot() Method

import java.lang.*;

public class Geeks {

public static void main(String[] args)

{

double num1 = 4;

double positive_Infinity = Double.POSITIVE_INFINITY;

double negative_Infinity = Double.NEGATIVE_INFINITY;

double nan = Double.NaN;

// When 1 or more argument is NAN

double hypotlen = StrictMath.hypot(nan, num1);

System.out.println("Hypotenuse length = " + hypotlen);

// When both arguments are infinity

hypotlen = StrictMath.hypot(positive_Infinity,

negative_Infinity);

System.out.println("Hypotenuse length = " + hypotlen);

}

}

输出:

Hypotenuse length = NaN

Hypotenuse length = Infinity

java hypot_Java StrictMath hypot()用法及代码示例相关推荐

  1. java hypot_Java StrictMath hypot()用法及代碼示例

    根據基本幾何形狀,斜邊僅是right-angled三角形的最長邊.它是與三角形直角相反的一側.為了找到right-angled三角形的斜邊的長度,應用勾股定理.根據該定理,給定長度為p和b的三角形的兩 ...

  2. java sinh_Java StrictMath sinh()用法及代码示例

    java.lang.StrictMath.sinh()方法用于返回作为参数传递给函数的双精度值的双曲正弦值. x的双曲正弦由下式定义 其中e表示欧拉号码 用法: public static doubl ...

  3. java hypot_Java StrictMath hypot()方法

    Java StrictMath hypot()方法 java.lang.StrictMath.hypot() 方法返回 sqrt(x2 + y2) 没有中间溢或下溢.它包括了一些情况: 如果任一参数为 ...

  4. java hypot_Java StrictMath hypot()方法与示例

    StrictMath类hypot()方法hypot()方法在java.lang包中可用. hypot()方法用于返回sqrt(sq(d1)+ sq(d2))的平方根,而不进行任何中间运算,换句话说,它 ...

  5. java 求tan的角度_Java StrictMath tan()用法及代码示例

    java.lang.StrictMath.tan()是Java中的内置函数,它返回角度的三角正切. 用法: public static double tan(double ang) 参数:该函数接受单 ...

  6. java中skip的用法,Java PushbackReader skip(long)用法及代码示例

    Java中的PushbackReader类的skip(long)方法用于跳过流中指定数量的字符.此字符数被指定为参数.如果通过跳过到达流的末尾,它将阻塞流,直到它获得一些字符或抛出IOExceptio ...

  7. math.hypot java_Java Math hypot()用法及代码示例

    java.lang.Math.hypot()函数是Java中的内置数学函数,可返回欧几里得范数, .函数返回sqrt(x2+ y2),而不会出现中间上溢或下溢. 如果任何一个参数都是无限大,则结果为正 ...

  8. java sliplist_Java List retainAll()用法及代码示例

    此方法用于将指定集合中存在于集合中的所有元素保留到列表中. 用法: boolean retainAll(Collection c) 参数:此方法只有一个参数,即要在给定列表中保留哪些元素的集合. 返回 ...

  9. java doublebuffer_Java DoubleBuffer clear()用法及代码示例

    java.nio.CharBuffer类的clear()方法用于清除此缓冲区.在清除此缓冲区时,需要进行以下更改: 位置设置为零 限制设置为容量 商标被丢弃. 用法: public final Dou ...

最新文章

  1. ONAP — CCVPN 跨域 SDN 协同编排
  2. c++内存分配的方式
  3. 洛谷P1074:靶形数独(搜索、剪枝)
  4. * 类描写叙述:字符串工具类 类名称:String_U
  5. 2019年7月数据库流行度排行:Oracle王者归来获大幅增长
  6. iPhone 11运存、电池确定!5499元值得买吗?
  7. asp.net性能优化之使用Redis缓存(入门)
  8. mysql数据库导入导出sql文件
  9. vueAdmin-template-master十次方后台项目前端(已经完成初始化)下载地址
  10. 测量系统分析方法(GRR Correlations Bias)
  11. 解决fatal error C1060: 编译器的堆空间不足(详解)
  12. springboot连接数据库用户名密码加密
  13. html—table(房屋楼层显示以及根据不同类型进行背景颜色区分)
  14. Springboot整合JDBC和DBUtils,实现简单的增删改查.
  15. 了不起的Node.js: 将JavaScript进行到底(Web开发首选,实时,跨多服务器,高并发)...
  16. 移动游戏性能优化通用技法
  17. 北航991——软件工程过程
  18. 精简XP系统添加韩文输入法,太难了
  19. 电大计算机专业英语形成性考试,《计算机专业英语》形成性考核册答案
  20. thymeleaf的使用

热门文章

  1. cd短是什么意思,王者荣耀:是不是技能cd越短难度就越大?看她就明白了
  2. Aspose.Words 表格添加斜线 并添加文字
  3. IoT当前最重要的机遇,全面解读专为边缘计算而生的EdgeX Foundry
  4. 查看已删除好友聊天记录
  5. win10下docker部署nginx+node+mongodb+redis学习
  6. Truffle Unbox failed问题解决方法
  7. html把一张图片动态的代码,AI不仅会P图了,还能让照片“动起来”!
  8. 有感觉,有深意的说辞
  9. new className() new出来的深意
  10. 蓝桥杯2017国赛 瓷砖样式 dfs+map