alright im on chapter 9 should i learn that?

or skip the math?

or would it be good to learn it cause you will use chapter 9 in other chapters?

anyways im doing the math. but

1 question

on page 53 where is says

float result = (float)(3.0/5.0) + 1;

in number 1. it says "taking 3.0 and dividing by 5.0 to get 0.6 as a double" <— but its a float not a double… because "float result"

to me "float result = (float)(3.0/5.0) + 1;" <- says its converting a float to a float….

and number 2. says pretty much the same thing converting the double into a float… but its already a float…

because a float has decimals, and so does a double..

doing your try it out on page 35.

looks right???

double a = 1.0 + 1 + 1.0f; //everynumber will be added up as a double even the last one which is a float. All 3 numbers will turn into 3.0 as a double.

int x = (int)(7 + 3.0 / 4.0 * 2); //the variable will do the math bracket first. then the va type will still be an int because int was never changed.

Console.WriteLine((1 + 1) / 2 * 3); // 1 + 1 will be done first then 1 / 2 then * by 3

Console.WriteLine(x);

Console.ReadKey();

--------— i dont understand this… can u do each paragraph visually? ty

double a = 1.0 + 1 + 1.0f;

In this equation, everything is using addition, so we start working left to right. 1.0 + 1 is the first step. These two representations of 1 aren't the same type though. In fact, none of the three are.

The first is a double, the second is an int, and the last is a float.

So in order to do 1.0 + 1, we need to convert one type to another. Since the double type is "wider" than the int type, we'll move things up to the double type. We'll convert the int version to a double, and to 1 + 1 using double types, resulting in 2.0 as a double.

Next we do the other addition. This has the same problem, though, because we'll be adding our result from the first step (a 2 as a double) to a float. So again, the float gets converted up to a double and we do the addition using doubles.

We now have a value of 3 that is the double type, which we can simply store in our a variable without any conversions at all, since our value is already a double type.

anyways i think i kidna understand casting and types.

anyways.

this part i dont get a little

int x = (int)(7 + 3.0 / 4.0 * 2);

is "(7 + 3.0 / 4.0 * 2)" <— a double no matter what?

or the double only applies if "int x" was "float x"?

or no matter what type it will always be a double?

Yeah. The `(7 + 3.0/4.0 * 2)` is what's called an "expression", which always evaluates to some sort of value, and that value always has a type of some sort. It doesn't matter what the type of the variable is that you want to assign it to, this expression will always evaluate to a double. Now that's problematic if you want to store it in a variable that's not the same type, but that's what the casting is for.

im on the infinity and nan stuff now.

wondering

double a = double.PositiveInfinity;

float b = float.PositiveInfinity;

what is the use for the value line…?

if i write

console.writeline(a);

it will just show "infinity"

and with NaN same thing..

so whats to special about writing the word "infinity" and "NaN" in console..?

It's not just about showing "infinity" or "NaN" in the console window. It's about the fact that double or float can both represent those sort of abstract concepts without problem. So if you end up doing 3 divided by 0 (as a floating point value, not an integer) your result will be NaN.

The number `e` is this thing. It's a seemingly obscure random number that turns out to show up over and over again in the world of math.