Hello everyone, I have a few problems with float not working like I think it should...? Using TCC to compile.
Basically, I'm trying to implement functions to calculate radians, degrees and powers.
Code:
#include <stdio.h>
#define PI 3.14159265
int main(void){
double rads = myrad(90); // Should be 1.570796
double degs = mydeg(rads); // Should be 90.000000
double pows = mypow(2, 4); // Should be 16.000000
printf("90 degrees to radians = %lf\n", rads);
printf("1.570796 radians to degrees = %lf\n", degs);
printf("2^4 = %lf\n", pows);
return 0;
}
int mypow(double x, double y){
double i = 0;
double power = 1;
while(i < y){
power *= x;
i++;
}
return power;
}
int myrad(double x){
double radians = x * PI / 180;
return radians;
}
int mydeg(double x){
double degrees = x / PI * 180;
return degrees;
}
The output is:
Code:
90 degrees to radians = 0.000000
1.570796 radians to degrees = 0.000000
2^4 = 0.000000
I can't change the "int"s to "double"s because TCC throws a
Code:
main.c:*insert_line*: error: incompatible types for redefinition of '*insert_function*'
at me.
Can anyone please help me with this, as I'm trying to teach myself with some books.