This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: issue with floor()


> From: David Brennan
> 
> I am using a relatively recent CVS of eCos on an x86 VME 
> target. I am trying to get an existing application working, 
> and I stumbled across an unusual result.
> 
> The code called floor() with a value of 0.048000000000000001. 
> the correct return value should have been 0.0.
> 
> Single stepping through the "bit twiddling" looked like it 
> was pursuing the correct code path, but at this point, 
> somthing went wrong.
> 
> 97	                if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */
> (gdb) s
> 98	                    if(i0>=0) {i0=i1=0;}
> (gdb) p i0
> $4 = 8
> (gdb) s
> 131	}
> (gdb) info locals
> i0 = 8
> j0 = -5
> i = 1067989024
> x = 0.048000000000000001
> (gdb) li
> 126	            }
> 127	        }
> 128	        CYG_LIBM_HI(x) = i0;
> 129	        CYG_LIBM_LO(x) = i1;
> 130	        return x;
> 131	}
> 132	
> 133	#endif // ifdef CYGPKG_LIBM
> 134	
> 135	// EOF s_floor.c
> 
> It appears that the code did not run line 98 correctly.

<snip>

> I am using a compiler that I built (so that is most likely 
> the problem). I am using OS X for my host, and there are not 
> pre-built binaries for that.

I would think examining the assembly language would clear up the mystery,
especially if you find the problem persists with optimization turned off.
For instance, it could be that the arithmetic doesn't work because
something's busted in the FP support, but the sign test works correctly
because it doesn't use an FP instruction to test the sign.

-- 

Ciao,               Paul D. DeRocco
Paul                mailto:pderocco@ix.netcom.com 


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]