Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

double bound by 2 other doubles

finjulhich
Beginner
316 Views

Hello,
what is the fastest way to test at runtime, to machine accuracy,
if double d2 is between d1 and d3 while not knowing d1 and d3 in advance?

double d1 =...;
double d2 =...;
double d3=...;
if ( d1>d3 && d1>=d2 && d2>=d3 ) || ( d1

regards,

0 Kudos
3 Replies
TimP
Honored Contributor III
316 Views
The answer is highly platform and data dependent. You might consider whether & in place of &&, | in place of ||, might be appropriate for your case.
0 Kudos
finjulhich
Beginner
316 Views

win64
core2 (up to ssse3) and penryn (sse4)
d1, d2, d3 are all within 0.0 and 1.0 range, but often between 0.0 and 0.1 range. relevant precision is 4th decimal.

i don't see how to use the bit-and and bit-or instead of logical ones.
rds,

0 Kudos
jimdempseyatthecove
Honored Contributor III
316 Views
// highest prob. lowest prob.
if((d1// d2 between d1 and d3 regardless of sign
}
order the expressions left to right in order of highest probability
If your code requires d1 < d3 then use only left expression
Jim

					
				
			
			
				
			
			
			
			
			
			
			
		
0 Kudos
Reply