Hello back, On Sun, Apr 10, 2011 at 12:11:56AM +0200, Lluís Batlle i Rossell wrote: > Further investigations showed that there is some place where 'signaling nan' > and > 'quiet nan' are MIXED. > > For example, the C++ numeric_limits<double> in mips encodes the quiet nan this > way: 0x7ff7ffffffffffff > > and the signaling nan this way: 0x7fffffffffffffff
The difference above is the most significant bit of the fraction. I checked the manual (loongson2f user guide), and it says: "For all floating-point formats, if v is NaN, the most-significant bit of f determines whether the value is a signaling or quiet NaN: v is a signaling NaN if the most-significant bit of f is set, otherwise, v is a quiet NaN." So it means that the values in numeric_limits are correct according to the manual. But further checking with the C++ program below (which you have to modify to make it use madd with a quiet nan passing the 'f') showed that all 'extra fp instructions' look affected by this: madd.d, msub.d, nmadd.d and nmsub.d. Only when having a qnan in any of the registers. The a-number cases, and signaling nan, work without signal. Gcc rendered *and called* those instructions only with "-O1". Trying other -O values, that got into different instructions, and *none of them* got a signal, either it was a signaling or a non-signalin nan. Regards, Lluís > Here is the C++ code I used. Change it at will to test: > ---------------- > #include <limits> > #include <math.h> > #include <iostream> > > double madd(double a, double b, double c) > { > return a*b+c; > } > > int main() > { > double z = 0; > double f = std::numeric_limits<double>::quiet_NaN(); > > double g = madd(z, 1, 1); > > std::cout << "primer: " << g << std::endl; > > f = std::numeric_limits<double>::signaling_NaN(); > > g = madd(z, f, f); > > std::cout << "segon: " << g << std::endl; > > return 0; > } > ---------------- -- You received this message because you are subscribed to the Google Groups "loongson-dev" group. To post to this group, send email to loongson-dev@googlegroups.com. To unsubscribe from this group, send email to loongson-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/loongson-dev?hl=en.