I am trying to do some trigonometry within EasyC and I have ran into a few questions.
When using a trig function, EasyC recommends using a ‘double’ variable type.
The ‘double’ variable type has a range of 2e^-308 to 2e^+308, including 6 decimal points. However, this is a 64 bit variable.
Is there any reason I shouldn’t use a ‘float’ variable type instead? It has a range of e^-38 to e^38, including 6 decimal points. Trig functions fall well within this range.
I know the extra 32 bits isn’t much, but i figure it’s good practice to use memory as efficiently as possible.
Would there be any unforeseen side effect to using a ‘float’ instead of a ‘double’ for trig functions?
Secondly, how well do non-decimal carrying variable types handle being assigned values that have a decimal tail?
For example, say I have the ‘float’ variable “A” that I have already limited between -127 and 127.
Say “B” is a ‘char’ variable type.
What happens if I do:
If “B” has a decimal value is it truncated or rounded? Or does something bad happen?