Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AspectJ » operator precedence issue?(mandrelbot problem)
operator precedence issue? [message #699547] Thu, 21 July 2011 18:34
Jonathan Camilleri is currently offline Jonathan CamilleriFriend
Messages: 91
Registered: July 2009
Member
The attached source code (lines 61-62) are used to create a graphic drawing as illustrated within Core Java Volume 2 (7th Edition).

However, when walking through the code, I noticed that putting a breakpoint at lines 61/62,and, reading the values does not completely agree with my manual calculation:
...
for (int i = 0; i < width; i++)
for (int j = 0; j < height; j++)
{
double a = XMIN + i * (XMAX - XMIN) / width;
double b = YMIN + j * (YMAX - YMIN) / height;
if (!escapesToInfinity(a, b))
raster.setDataElements(i, j, colorData);
}
return image;
...

XMIN = -2.0
XMAX = 2.0
YMIN = -2.0
YMAX = 2.0

for i = 0 and j = 0

a = -2 + 0 * (2 - (-2)) /400 = -0.02
b = -2 + 0 * (2 - (-2)) /400 = -1.99

When debugging the code Eclipse reads -2.0 for both a and b, as intermediate values. Where am I confused or misled?

Information about Mandrelbot, and, the rationale behind these formulae would be appreciated.

Complete source code which is sourced from Core Java Volume 2 (7th Edition) is attached to reproduce the issue.

Is this a bug or a misunderstanding?

[Updated on: Fri, 22 July 2011 05:55]

Report message to a moderator

Previous Topic:C/C++ Programs From Java using JNI
Next Topic:Error when trying to make a New XML file
Goto Forum:
  


Current Time: Thu Apr 25 08:31:57 GMT 2024

Powered by FUDForum. Page generated in 0.03161 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top