Cos(1.5708) = -3.61999014e-06 Why?

float posX = cos(1.5708f)

posX = -3.61999014e-06;

It should be zero

Why is this

Is this a cocos issue ? Should I inlcude my own math.h and use std::??

Cant figure this out

Thanks

I always use std:: or for high precision boost.

I think what you are looking for is cosf()

But it has nothing to do with cocos :slight_smile:

1 Like

use std:: OR high precision boost ? Whats this boost thing assuming its not std:: ?

cosf() gives same error

Well i just wondered because i can just use cos(0 without std::cos() … I was wondering if it was because cos() is a cocos fucntion

float posX = cosf(1.5708f);

log("posX %f", posX);  

this outputs posX -0.00004

Not for me it is not ! Strange right !! Ill make video now for you

Do you wanna see with team viewer, i bet this is got ya interest ?? :slight_smile:

Sorry I am actually at work right now… it would be better to make a video.
thanks

1 Like

You mind me asking what you work as. ? :no_mouth:

Game dev :stuck_out_tongue:

A cool, i was hoping for that answer !! I want also to just make games. My goodness do not stick me super macs

you may or may not know that the “e-06” means move the decimal point 6 places to the left. So your code gives:

posX = -0.00000361999014

which is correct! (obviously 1.5708 is only an approximation of Pi/2.0 so the answer isnt exactly 0.0. Maybe try cos(1.57079632679f)?)

2 Likes

Holy banana. So we all good . Let me test

Well, we can’t be good at everything. :slight_smile:

1 Like

My man. I suppose I just am silly… Like what bilalmirza said below worked for me fine, I think I was over debugging, jumping to conclusions and forgetting the meaning of that e-06 thing

Thanks, guys. So there was no issue at all. Just stupid me

My Man :+1:

1 Like