Community
Participate
Working Groups
Build Identifier: The attached source code (lines 61-62) are used to create a graphic drawing as illustrated within the attached source code. 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. JLS reads as follows for the multiplication operator (15.17.1): Multiplication is a commutative operation if the operand expressions have no side effects. While integer multiplication is associative when the operands are all of the same type. References 1. Core Java Volume 1 (8th Edition), Table 3.4 ISBN-13: 978-0-13-235476-9 2. Core Java Volume 2 (7th Edition), ISBN 0-13-111826-9. 3. Java Language Specification (3rd Edition) 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. Reproducible: Always
Created attachment 200143 [details] source
Created attachment 200144 [details] screenshot
(In reply to comment #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. In the case mentioned the values for a and b are correct (-2) and Eclipse is showing these correct values. > Information about Mandrelbot, and, the rationale behind these formulae would be > appreciated. Google would be a good place to start for information about Mandelbrot.