CSE 14 Lecture Notes - Lecture 7: Infinite Loop, Negative Number, Indium Phosphide

40 views7 pages
25 Apr 2018
School
Course
Professor

Document Summary

Cmps12a lecture 7 pa2 stuff and functions. Math. random() returns a double from 0 to less than 1, which is [0, 1) specifically. Calling on that method can return 0, 0. 15, 0. 874, 0. 971232145, etc. Once the double value has been acquired, one needs to change it to an integer from the range. 0 to 10 in order to continue with pa2. Do the calculation and you will see that the numbers now change from 0 to less than 10, but they are still a double number! Thus, we now perform the conversion this way: Example: double x = 5; //this is 5. 0 int y; //this is the variable where you will store the integer value of the double y = (int) x; //this method converts the double value of x to an integer, by putting (int) before the x variable and then storing it into y, which is of integer type.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions