Bug 95293

Summary: [chromium] Use floating point literals in expressions that initialize floats
Product: WebKit Reporter: James Robinson <jamesr>
Component: New BugsAssignee: James Robinson <jamesr>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, cc-bugs, danakj, dglazkov, enne, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

James Robinson
Reported 2012-08-28 23:30:20 PDT
[chromium] Use floating point literals in expressions that initialize floats
Attachments
Patch (2.97 KB, patch)
2012-08-28 23:32 PDT, James Robinson
no flags
James Robinson
Comment 1 2012-08-28 23:32:49 PDT
Adam Barth
Comment 2 2012-08-28 23:54:06 PDT
Comment on attachment 161144 [details] Patch This is technically against WebKit style, but given that this code is going to GTFO, this seems fine.
WebKit Review Bot
Comment 3 2012-08-29 01:42:36 PDT
Comment on attachment 161144 [details] Patch Attachment 161144 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/13690106 New failing tests: CCLayerTreeHostTestAtomicCommitWithPartialUpdate.runMultiThread
WebKit Review Bot
Comment 4 2012-08-29 03:51:53 PDT
Comment on attachment 161144 [details] Patch Clearing flags on attachment: 161144 Committed r126981: <http://trac.webkit.org/changeset/126981>
WebKit Review Bot
Comment 5 2012-08-29 03:51:56 PDT
All reviewed patches have been landed. Closing bug.
Dana Jansens
Comment 6 2012-08-29 07:51:17 PDT
For those of us not building with VS, should we always be using f suffix? It surprises me that these are the only double literal->float truncations in our code base, are these somehow special?
Adam Barth
Comment 7 2012-08-29 08:24:00 PDT
> For those of us not building with VS, should we always be using f suffix? Nope. > It surprises me that these are the only double literal->float truncations in our code base, are these somehow special? They're special because we're in the process of moving this code out of WebKit to a location where more warnings are enabled.
Dana Jansens
Comment 8 2012-08-29 08:27:41 PDT
(In reply to comment #7) > > For those of us not building with VS, should we always be using f suffix? > > Nope. > > > It surprises me that these are the only double literal->float truncations in our code base, are these somehow special? > > They're special because we're in the process of moving this code out of WebKit to a location where more warnings are enabled. Right, I am wondering about future compositor code, not WebKit :) For example we have tons of things like FloatPoint(0.5, 0) in our tests. These are using a double literal for a float as well, but are not causing compiler warnings?
James Robinson
Comment 9 2012-08-29 09:21:47 PDT
The WebKit style is "use f if you need to force floating-point math". In this instances, we need to force floating point math or MSVS warns (somewhat correctly) that the narrowing conversion is lossly. Initializing to 0.5, 0 probably doesn't need anything since 0.5 and 0 are exactly representable as doubles and floats, so it's not lossy. I'm guessing that since 0.1, 0.01, and 0.95 do not have exact representations as doubles or floats, and the float representation is not equivalent to the double representation, the compiler is less happy.
Note You need to log in before you can comment on or make changes to this bug.