<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -201,22 +201,28 @@ class ImageTool {
 		}
 		else {
 			boolean tall = (height * (maxWidth / maxHeight) &gt; width);
-			float modifier = maxWidth / (float) (tall ? (height * (maxWidth / maxHeight)) : width);
+			double modifier = maxWidth / (float) (tall ? (height * (maxWidth / maxHeight)) : width);
 			ParameterBlock params = new ParameterBlock();
 			params.addSource(image);
 
-			/* Had to do this because of that the different rendering options require either float or double */
+			// We had to do this because of that the different rendering 
+			// options require either float or double.  This ended up having
+			// a side effect of Java apparently not correctly converting from
+			// floats to double, so we have to keep the value as a double
+			// and then convert to float when necessary
 			switch (renderingType) {
-				case 1: params.add(modifier);//x scale factor
-					params.add(modifier);//y scale factor
-					break;
-				case 2: params.add((double) modifier);//x scale factor
-					params.add((double) modifier);//y scale factor
+				case 1: 
+					params.add((float)modifier);//x scale factor
+					params.add((float)modifier);//y scale factor
 					break;
-				default:
+				case 2: 
 					params.add(modifier);//x scale factor
 					params.add(modifier);//y scale factor
 					break;
+				default:
+					params.add((float)modifier);//x scale factor
+					params.add((float)modifier);//y scale factor
+					break;
 			}
 
 			params.add(0.0F);//x translate</diff>
      <filename>src/groovy/org/grails/plugins/imagetools/ImageTool.groovy</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ae8b7255b72bce996c716c9ebba260cf5112a247</id>
    </parent>
  </parents>
  <author>
    <name>Ricardo J. Mendez</name>
    <email>ricardo@arquetipos.co.cr</email>
  </author>
  <url>http://github.com/ricardojmendez/grails-imagetools/commit/f0484422d22fc5ca209d33f5ce8642f6a41c4d3a</url>
  <id>f0484422d22fc5ca209d33f5ce8642f6a41c4d3a</id>
  <committed-date>2009-09-04T21:31:16-07:00</committed-date>
  <authored-date>2009-08-20T20:30:07-07:00</authored-date>
  <message>Workaround for a float -&gt; double conversion bug

Joshua Braegger reported a bug caused by a float to double conversion.  The
bug is exemplified by the following Groovy code:

    float maxWidth = 440
    int width = 2000
    float modifier = maxWidth / width
    println( (double) modifier) // prints 0.219999 ... should print 0.22

This affected ImageTool.thumbnailSpecial, which needs to keep a modifier
value as either a float or a double and convert to the other, since the
JAI APIs sometimes receive one and sometimes the other.

On my tests, the bug does not appear when keeping the value as a double and
converting to a float, so I've changed it to that implementation.</message>
  <tree>0c202c72d743ac81bd4682c91b9ab4a5161877bc</tree>
  <committer>
    <name>Ricardo J. Mendez</name>
    <email>ricardo@arquetipos.co.cr</email>
  </committer>
</commit>
