English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Please do not use any conditional statements.(if,conditional operators)

2007-03-14 06:55:09 · 2 answers · asked by Deepak Kotla 2 in Computers & Internet Programming & Design

2 answers

x > y ? x : y

equivalent to

if(x > y) { return x; } else { return y; }

2007-03-14 07:13:13 · answer #1 · answered by Anonymous · 0 0

if ((a-b) & 0x80) bigger = b;

if b>a then (a-b) will be negative, meaning the MSB of a-b will be 1. When you AND it with 0x80, the result it only MSB bit. Now if the result is zero you know that first bit is zero, implies (a-b) >0, implies a>b. In other case, when the result is non-zero, (a-b)<0, implies (a

2007-03-14 17:20:08 · answer #2 · answered by manoj Ransing 3 · 0 0

fedest.com, questions and answers