is this ok?

Started by
7 comments, last by th3matr1x 18 years, 10 months ago
I took those too screenshots, when i was debugging using MS Visual studio. I'm not sure about the first one. but the second one shows some very strange output numbers. compare the input and output results with the one that are computed with the sine object. I dunno how the debugger worked out those numbers :)



I love programming
Advertisement
Nothing wrong in shot one, 3.4 is evidently not possible to represent absolutely in floating point representation. What Every Computer Scientist Should Know About Floating-Point Arithmetic
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
Quote:Original post by antareus
Nothing wrong in shot one, 3.4 is evidently not possible to represent absolutely in floating point representation. What Every Computer Scientist Should Know About Floating-Point Arithmetic


And what about the second one :)
how can it happen that the output is wrong?
I love programming
Ahh I see what you're getting at... ok so where/how is o_output and o_input defined? are they in a union?

just to confirm:
you are expecting o_output[0] to be 0.0 (but you are seeing 0.778...)
you are expecting o_output[1] to be 0.997... (but you are seeing 0.0)
Quote:Original post by superdeveloper
Ahh I see what you're getting at... ok so where/how is o_output and o_input defined? are they in a union?

just to confirm:
you are expecting o_output[0] to be 0.0 (but you are seeing 0.778...)
you are expecting o_output[1] to be 0.997... (but you are seeing 0.0)


double *o_input and double *o_output
I love programming
Am I right in assuming here that o_ouput[0] and o_output[1] are initialized with a non-bogus value before this computation?
On the top of my head:

a) did you included (or better: ) at the beginning of your cpp file?
b) are you sure you didn't create another sin() function (maybe a member function of your Sin class) which behaves diferently than the original one?

Regards,
^^ was me.

Corrected first point:

a) did you included <math.h> (or better: <cmath>) at the beginning of your cpp file?

Better with these...

Sorry [ashamed]
but somhow the calculation is right when i start without debugging.
how can this happen?
I love programming

This topic is closed to new replies.

Advertisement