C/C++
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives FAQs C/C++

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old August 1st, 2008, 07:19 AM
asutic
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
rounding of 4 unsigned char numbers

Hi. I've encountered a problem with rounding which I cannot resolve
elegantly and I has hoping that somebody could help me out. Here's the
problem description:

We are given 4 numbers a, b, c, and d in the range [0255]. These are
8-bit numbers (unsigned char), but I assume that the solution should
exists for any non-negative integer. We are supposed to determine x =
x(a, b, c, d) so that the following 2 formulas give identical results:

(a + b + c + d + 2) >2 = (((a + c + 1) >1) + ((b + d + 1) >1) +
x) >1

This means that the ceiling of quarter sum of 4 numbers should be
accomplished in 2 steps.

Similar formula should be applied for flooring of quarter sum of 4
numbers:

(a + b + c + d) >2 = (((a + c) >1) + ((b + d) >1) + x) >1

Any ideas how can we do this elegantly? It looks like the solution
inspects if a, b, c, d are odd or even, plus if they are divisible by
4.

Thanks in advance for your help! I'd really appreciate it.

Regards,
Aleksandar

Reply With Quote
Reply

Viewing: Web Development Archives FAQs C/C++ > rounding of 4 unsigned char numbers


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek