java math.sin用法_Java StrictMath sin()用法及代码示例

java.lang.StrictMath.sin()是Java中的内置函数,它返回角度的三角正弦值。

用法:

public static double sin(double ang)

参数:该函数接受单个参数ang,它是一个双变量,表示一个角(以弧度表示),该角的三角正切值将由该函数返回。

返回值:此方法返回作为参数传递给函数的角度的正弦值。考虑以下情况:

如果参数为NaN或无穷大,则该函数返回NaN。

如果参数为零,则该函数将返回零,其符号与参数的符号相同。

例子:

Input : ang = 0.5235987755982988(30 degree)

Output : 0.49999999999999994

Input : ang = 0.7853981633974483(45 degree)

Output : 0.7071067811865475

以下程序说明了Java中java.lang.StrictMath.sin()函数的工作方式:

示例1:

// Java Program to illustrate sin()

import java.io.*;

import java.math.*;

import java.lang.*;

class GFG {

public static void main(String[] args)

{

double ang = (60 * Math.PI) / 180;

// Display the trigonometric sine of the angle

System.out.println("Sine value of 60 degrees : "

+ StrictMath.sin(ang));

}

}

输出:

Sine value of 60 degrees : 0.8660254037844386

示例2:

// Java Program to illustrate sin()

import java.io.*;

import java.math.*;

import java.lang.*;

class GFG {

public static void main(String[] args)

{

double ang = 77.128;

// Convert the angle to its equivalent radian

double rad = StrictMath.toRadians(ang);

System.out.println(rad);

// Display the trigonometric sine of the angle

System.out.println("Sine value of 77.128 degrees : "

+ StrictMath.sin(rad));

}

}

输出:

1.3461375454781863

Sine value of 77.128 degrees : 0.9748701783788553

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Android development is hot, and many programmers are interested in joining the fun. However, because this technology is based on Java, you should first obtain a solid grasp of the Java language and its foundational APIs to improve your chances of succeeding as an Android app developer. After all, you will be busy learning the architecture of an Android app, the various Android-specific APIs, and Android-specific tools. If you do not already know Java fundamentals, you will probably end up with a massive headache from also having to quickly cram those fundamentals into your knowledge base. Learn Java for Android Developmentteaches programmers of any skill level the essential Java language and foundational Java API skills that must be learned to improve the programmer''s chances of succeeding as an Android app developer. Each of the book''s 10 chapters provides an exercise section that gives you the opportunity to reinforce your understanding of the chapter''s material. Answers to the book''s more than 300 exercises are provided in an appendix. Once you complete this book, you will be ready to dive into Android, and you can start that journey by obtaining a copy ofBeginning Android 2. Additionally, author Jeff Friesen will provide supplementary material (such as 6 more chapters) on his javajeff.mb.ca website, available over the next few months following this book''s release. What you''ll learn The Java language: This book provides complete coverage of nearly every pre-Java version 7 language feature (native methods are briefly mentioned but not formally covered). Starting with those features related to classes and objects, you progress to object-oriented features related to inheritance, polymorphism, and interfaces. You then explore the advanced language features for nested types, packages, static imports, exceptions, assertions, annotations, generics, and enums. Continuing, you investigate strictfp, class literals, synchronized, volatile, the enhanced for loop statement, autoboxing/unboxing, and transient fields. The book also briefly presents most (if not all) of Java version 7''s language features, although not much is said about closures or modules (which were not finalized at the time of writing). Java APIs: In addition to Object and APIs related to exceptions, you explore Math, StrictMath, BigDecimal, BigInteger, Package, Boolean, Character, Byte, Short, Integer, Long, Float, Double, Number, the References API, the Reflection API, String, StringBuffer, System, the Threading API, the collections framework, the concurrency utilities, the internationalization APIs, the Preferences API, Random, the Regular Expressions API, File, RandomAccessFile, stream classes, and writer/reader classes. You will also get a tiny taste of Swing in the context of internationalization. Tools: You will learn how to use the JDK''s javac (compiler), java (application launcher), javadoc (Java documentation generator), and jar (Java archive creator, updater, and extractor) tools. You will also receive an introduction to the NetBeans and Eclipse integrated development environments. Although you can develop Android apps without NetBeans or Eclipse, working with these IDEs is much more pleasant. Who this book is for This book is for any programmer (including existing Java programmers and Objective-C (iPhone/iPad) programmers) of any skill level who needs to obtain a solid understanding of the Java language and foundational Java APIs before jumping into Android app development. Table of Contents Getting Started with Java Learning Language Fundamentals Learning Object-Oriented Language Features Mastering Advanced Language Features Part 1 Mastering Advanced Language Features Part 2 Exploring the Basic APIs Part 1 Exploring the Basic APIs Part 2 Discovering the Collections Framework Discovering Additional Utility APIs Performing I/O Solutions to Exercises

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值