This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
http://lists.w3.org/Archives/Public/public-canvas-api/2010AprJun/0005.html From: public-canvas-api-request@w3.org [mailto:public-canvas-api-request@w3.org] On Behalf Of Jatinder Mann Sent: Wednesday, April 14, 2010 12:01 PM To: public-canvas-api@w3.org Subject: Floating point number tolerance I came across an issue regarding floating point numbers. The specification doesn't clearly define how close two floating point numbers have to be before they are considered the same number. For example, the following code may result in either a tiny arc or a complete circle, depending on how the user agent implement floating point tolerance: 0 ctx.lineWidth = 1; 1 var diff = 0.01; 2 ctx.beginPath(); 3 ctx.arc(100, 100, 100, 0, 2*Math.PI-diff, true); 4 ctx.stroke(); In my testing, Chrome, Firefox, Opera and Safari all show a tiny arc with this code. If the diff variable is changed to 0.001, all the above mentioned browsers show nothing. However, if the diff variable is changed to 0.00000001 Chrome, Firefox and Safari will show a full circle (treat the number as 0). Opera on the other hand will show a full circle when the diff variable is 0.0000000000000001. This same issue of tolerance applies to serialization of color, strokeRect(), closePath() and arc() functions. The spec should define how close two numbers need to be before they are considered the same number. Thank you, Jatinder Jatinder Mann | Microsoft Program Manager | jmann@microsoft.com
Philip mentions: http://lists.w3.org/Archives/Public/public-html/2008Apr/0770.html
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document: http://dev.w3.org/html5/decision-policy/decision-policy.html Status: Did Not Understand Request Change Description: no spec change Rationale: In the case of arc(), the spec is defined in terms of the difference between the angles, so I don't see how the code above could ever give a small arc, for any small value of diff. In general, though, isn't this defined by IEEE 754? I don't understand what you want the spec to say. I can't work out the relevance of this to serialization of color, strokeRect(), and closePath().