2020-02-16 11:15 PM
i could not found where float datatype is declared , and not working calcuation with float numbers
where library it contains ?
Thanks
Dipak garasiya
2020-02-16 11:45 PM
The floating-point types - float and double - are integral part of the C language. So, declaring floats and perform single operations requires nothing, so this
float a, b;
a = a + b * 3.1415926f;
should compile without any further action.
Some functions - e.g. trigonometrical, exponenctial/logarithm - are prototyped in <math.h>, and you may need to add a library to the linking process, but this is toolchain dependent.
JW
2020-02-17 12:14 AM
of course it is working if i declard any float data type and print value of float type variable
but when i want to show declartion of float data type given message displayed
" Selected text cannot be mapped to a symbol name " . why this happen
second thing is .
when i make follwing calcuation like
float a = 45/100;
it gives me zero value
when i typecast like that
float a = (float) 45/100
ti gives me correct answer
typecasting should be done automatically to upper data type but it is not working at all
2020-02-17 12:21 AM
> second thing is .
> when i make follwing calcuation like
> float a = 45/100;
> it gives me zero value
It is supposed to be that way.
Get a good C language tutorial.
Especially the chapters about casting and type promotion rules.
2020-02-17 02:02 AM
> Get a good C language tutorial.
> Especially the chapters about casting and type promotion rules.
+1
... and the chapter about constants.
Floating-point constants have to contain "." or "E"; and if you want them to be of float type not double type, you have to append the "f" suffix.
i.e.
float a = 45.0f/100.0f;
JW
2020-02-18 01:14 AM
thanks for reply ,