Trig trouble

Miscellaneous Forums/General Discussion/Trig trouble

Hi, I'm no trig expert, as demonstrated here:

Why doesn't Cos(90) equal zero? It comes out as -4.37114e-008 in Blitz3D.

Is it so that things like Atan(sin(a)/cos(a)) don't result in a division by zero, or something?

Dumb question? Probably.

[edit] Also, what actually is -4.37114e-008 as a recognizable float? I hate exponential notation. :P I'm assuming it's a number as close to zero as possible?

Floating point inaccuracy, is all.

Rounding errors - to do with the approximations used to calculate the result of cos. Just an unpleasant side effect, not a design aim.

I see - thanks.

The strange thing is, I don't want cos(90) to actually result in zero, for the reason I speculated about, above.

I'm doing:

x# = Cos(ang) * x_rad
y# = Sin(ang) * y_rad
new_ang# = ATan(y/x)

So, if cos(90) ever did hit 0, I'd hit a division by zero on y/x.

I guess I could've always added an epsilon value to x in that case, though. :)

Also, what actually is -4.37114e-008 as a recognizable float?
0.00000000437114 iirc.

The e-008 part indicates how many zeros.

The series used to calculate Cos, is a bit Like PI, in that it goes on and on and on, but at some point you need to say. "Thats its, its close enough"
So the writers of computer Cos series generaters have decided that as Computer Floats are only accruate to 8 points, once the series gets to changing only the eigth decimal point, there is no need to calculate anymore.
Its not really about rounding error (though thats there as well), but more to do with how long do you really want Cos to take?

(In Bmax its 6.1230317691118863e-017)

The e-008 part indicates how many zeros.
Oh. Is it that simple?! D'oh. :)

Cheers, all!

-4.37114e-008 means: -4.37114 * 10 ^ -8
e is just short for * 10 ^ ;)

Hmm. Pity blitz can't just decode that and print it in a form I can recognize. :)

Ahh, but it does, cos now you reconize it ;)

e = exponential???

Would I be write in thinking that?

it is a lot easier to read something like 5.362E100 than it is to read what that -actually- is.

it is just scientific notation, which was devised to let people understand crazy big and crazy small numbers. Which we have to use understand things like atoms and things like the universe, and the even smaller math puzzles people have thought up.

It's part of an old cold war plot to put American ink manufacturers out of business.


My brain wants me to say that the 'e' stands for engineering notation but, as AGamer said, it's more likely to be short for exponent...stoopid brain.

Are you sure it's in degrees, and not radians?

Cos (90) is -0.44807361612917015236547731439964 in Radians so..... Yep we are sure