M
Michael
Hi in here,
I have a problem with the following lines of code:
printf("\tCalc this:\t %f * (%f -%f) = %f\n",
tCtrl->dGain, *p_dDesiredValues, *p_dActualValues,
( tCtrl->dGain * (*p_dDesiredValues-*p_dActualValues )));
They are part of a function, where
tCtrl is a pointer to a struct
containing a double called
'dGain'
p_dDesiredValues Pointer to double
p_dActualValues Pointer to another double.
Sometimes the command gives the weird output:
Calc this: 6.000000 * (2.000000 -1.800000) = -1.#IND00
If I put the same statement twice, the second always gives:
Calc this: 6.000000 * (2.000000 -1.800000) = 1.200000
Well, the real thing is that this is not part of an
C-program, but an subroutine to an numerical math tool.
The subroutine is written in c.
I know this is off topic here. That's why I just want to
know if something of the above thing is wrong in 'c-sense',
or if it's ok and the error must be somewhere else.
Regards,
Michael
I have a problem with the following lines of code:
printf("\tCalc this:\t %f * (%f -%f) = %f\n",
tCtrl->dGain, *p_dDesiredValues, *p_dActualValues,
( tCtrl->dGain * (*p_dDesiredValues-*p_dActualValues )));
They are part of a function, where
tCtrl is a pointer to a struct
containing a double called
'dGain'
p_dDesiredValues Pointer to double
p_dActualValues Pointer to another double.
Sometimes the command gives the weird output:
Calc this: 6.000000 * (2.000000 -1.800000) = -1.#IND00
If I put the same statement twice, the second always gives:
Calc this: 6.000000 * (2.000000 -1.800000) = 1.200000
Well, the real thing is that this is not part of an
C-program, but an subroutine to an numerical math tool.
The subroutine is written in c.
I know this is off topic here. That's why I just want to
know if something of the above thing is wrong in 'c-sense',
or if it's ok and the error must be somewhere else.
Regards,
Michael