Hello friends!
Fisrt of all, I convey my heartful Thanks to all of them subscribed to this wonderful forum.
I would like to have you help me in solving a problem that i face with floating point variable positive/negative value conversion.
Problem scenario:
I declare a variable as float and a negative value is assigned in that by some other operation.later I want that same variable to hold the same value as positive value.hope C compiler has some kind of facility to operate this kind of problem.but i know not.so i seek ur help in this matter.
Example:
// so now "diff" can store either positive or negative value depends upon the value of "ave" and "a".If it stores positive value,i dun have any problem but if we presume "diff" stores a negative value say "-2.5" then after this above statement execution, I want the "diff" to hold only positive floating point value,'cos i will be using the value of "diff" in some other operation but only with positive value.
say diff = -2.5 then, i want the same variable to hold same value in positive i.e diff = 2.5 .then i will using "diff" in various other operations.
Hope to get ur help soon.
Thanks!
Ragards for helpers,
smaksmak.
Fisrt of all, I convey my heartful Thanks to all of them subscribed to this wonderful forum.
I would like to have you help me in solving a problem that i face with floating point variable positive/negative value conversion.
Problem scenario:
I declare a variable as float and a negative value is assigned in that by some other operation.later I want that same variable to hold the same value as positive value.hope C compiler has some kind of facility to operate this kind of problem.but i know not.so i seek ur help in this matter.
Example:
Code:
float a,;
float diff;
float ave;
diff=ave - a;
// so now "diff" can store either positive or negative value depends upon the value of "ave" and "a".If it stores positive value,i dun have any problem but if we presume "diff" stores a negative value say "-2.5" then after this above statement execution, I want the "diff" to hold only positive floating point value,'cos i will be using the value of "diff" in some other operation but only with positive value.
say diff = -2.5 then, i want the same variable to hold same value in positive i.e diff = 2.5 .then i will using "diff" in various other operations.
Hope to get ur help soon.
Thanks!
Ragards for helpers,
smaksmak.