chipKIT® Development Platform

Inspired by Arduino™

Problem with trig. functions

Created Wed, 31 Jul 2013 20:27:12 +0000 by jperk51


jperk51

Wed, 31 Jul 2013 20:27:12 +0000

if I do this the result is correct

void setup() { Serial.begin(9600); Serial.println(" "); Serial.println(acos(.5));

}

void loop() { }

but if I do it this way I get 4294967295.21474836472147483647

float thing = .5;

void setup() { Serial.begin(9600); Serial.println(" "); Serial.println(acos(thing)); }

void loop() { }


majenko

Thu, 01 Aug 2013 14:20:57 +0000

And if you use double instead of float?


jperk51

Thu, 01 Aug 2013 15:50:05 +0000

if I use a double it does the same thing. I wrote up another on that has variables like

int thing = .5; double thing2 = .5;

Serial.println(acos(thing)); Serial.println(acos(thing2));

and so on for every data type and they all gave me the same answer.


majenko

Thu, 01 Aug 2013 16:11:28 +0000

Which version of the IDE are you using? I know there was some changes made to this kind of thing at once point.