Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » U++ TheIDE and Library: Releases and ChangeLogs » Quiz: What is wrong with this code?
Re: Quiz: What is wrong with this code? [message #3958 is a reply to message #3953] Tue, 11 July 2006 17:25 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13983
Registered: November 2005
Ultimate Member
unodgs wrote on Tue, 11 July 2006 03:15

luzr wrote on Mon, 10 July 2006 17:16

struct Rect_ {
.....
	Pt     CenterPoint() const              { return Pt((left + right) / 2, (top + bottom) / 2); }
.....
};


...should compute the central point of Rect...

(...fixed).

Mirek


Interesting.. looks fine to me..

Normaly computation of center point looks like:

top + (bottom - top) / 2

but it evaluates to:

top + bottom / 2 - top / 2 =
top / 2 + bottom /2 =
(top + bottom) / 2

Is that bug related to const modifier??


No. The problem is when top and bottom are ints and top + bottom is negative - "evaluates" is no longer true....

Mirek

[Updated on: Tue, 11 July 2006 17:26]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Some macro enhancements for TheIde
Next Topic: Fixed QuickTabs DnD refreshing problems. Mouse wheel works in tiny bar too now..,
Goto Forum:
  


Current Time: Mon Jun 03 16:18:39 CEST 2024

Total time taken to generate the page: 0.01470 seconds