       "##{hexFromNumber(@r)}#{hexFromNumber(@g)}#{hexFromNumber(@b)}"  
 
     toHsl: ->
-      [r, g, b] = (channel / 255.0 for channel in [@r, @g, @b])
-
-      min = Math.min(r, g, b)
-      max = Math.max(r, g, b)
-
-      hue = saturation = lightness = (max + min) / 2.0
+      [r, g, b] = (channel / 255 for channel in [@r, @g, @b])
+
+      {min, max} = [r, g, b].extremes()
+
+      hue = saturation = lightness = (max + min) / 2
 
       if max == min
         hue = saturation = 0
       else
         chroma = max - min
-        saturation = (if lightness > 0.5 then chroma / (2.0 - 2.0 * lightness) else chroma / (lightness * 2.0))  
+
+        saturation =
+          if lightness > 0.5
+            chroma / (1 - lightness)
+          else 
+            chroma / lightness
+
+        saturation /= 2
 
         switch max
-          when r then hue = ((g - b) / chroma) + (if g < b then 6 else 0)
-          when g then hue = ((b - r) / chroma) + 2.0
-          when b then hue = ((r - g) / chroma) + 4.0
-
-        hue *= 60.0
+          when r then hue = ((g - b) / chroma) + 0
+          when g then hue = ((b - r) / chroma) + 2
+          when b then hue = ((r - g) / chroma) + 4
+
+        hue *= 60
 
       return [hue, saturation, lightness, @a]      
 

    switch hexString.length
      when 3, 4
        if hexString.length == 4
          alpha = ((parseInt(hexString.substr(3, 1), 16) * 0x11) / 255.0)
        else
          alpha = 1.0  

        rgb = (parseInt(hexString.substr(i, 1), 16) * 0x11 for i in [0..2])      
        rgb.push(alpha)    


      when 6, 8
        if hexString.length == 8
          alpha = (parseInt(hexString.substr(6, 2), 16) / 255)
        else
          alpha = 1

        rgb = (parseInt(hexString.substr(2 * i, 2), 16) for i in [0..2])          
        rgb.push(alpha)
