## How can I initialize a double variable to infinity 原

Oscarfff

Q. How can I initialize a double variable to infinity?

A. Java has built-in constants available for this purpose: Double.POSITIVE_INFINITY

and Double.NEGATIVE_INFINITY.

Q. Can you compare a double to an int?

A. Not without doing a type conversion, but remember that Java usually does the requisite type conversion automatically. For example, if x is an int with the value 3, then

the expression (x < 3.1)  is true—Java converts x to double (because 3.1 is a double

literal) before performing the comparison.

Q. What are the values of 1/0 and 1.0/0.0 as Java expressions?

A. The first generates a runtime exception for division by zero (which stops your program because the value is undefined); the second has the value Infinity

Q. Why do we say (a && b) and not (a & b) ?

A. The operators &, | , and ^ are bitwise logical operations for integer types that do and,

or, and exclusive or (respectively) on each bit position. Thus the value of 10&6 is 14 and

the value of 10^6 is 12. We use these operators rarely (but occasionally) in this book.

The operators && and ||  are valid only in boolean expressions are included separately

because ofshort-circuiting: an expression is evaluated left-to-right and the evaluation

stops when the value is known.

### Oscarfff

JavaScript Primitive Data Types

﻿JavaScript Primitive Data Types Primitive data types Any value that you use is of a certain type. In JavaScript, there are just a few primitive data types: 1. Number: This inc......

2014/07/16
0
0
java中的NAN和INFINITY

java浮点数运算中有两个特殊的情况：NAN、INFINITY。 1、INFINITY： 在浮点数运算时，有时我们会遇到除数为0的情况，那java是如何解决的呢？ 我们知道，在整型运算中，除数是不能为0的，否则...

2016/10/27
7
0
Creating a Turing Machine in Python – Part 2

In the last part, we covered the theory of Turing machines and created the basic project structure and classes. Now we are going to implement those classes one by one. direction......

Philipp_Engelmann
2017/12/22
0
0
C# 中的 Infinity 和 NaN

C#语言中，对于 int，long 和 decimal类型的数，任何数除以 0 所得的结果是无穷大，不在int，long 和 decimal 类型的范围之内，所以计算 6/0 之类的表达式会出错。 但是，double 和 float 类...

ucliaohh
2015/09/02
702
2

go4it
2018/08/31
0
0

onedotdot
31分钟前
1
0
MVC、MVCS、MVVM、MVP、VIPER等这么多架构模式哪一个好呢？

Java干货分享

4
0

//Student类 public class Student { public void love() { System.out.println("python"); } } //Tesy类 public class Tesy { public static void main(String[] args) throws Exceptio......

2
0

1
0

linux-tao

5
0