[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.17-1283-gcf603cf
mitz at apple.com
mitz at apple.com
Tue Jan 5 23:48:38 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 59cefabbd4d431710eb8503d0654ab52c2c3eba6
Author: mitz at apple.com <mitz at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Dec 14 00:14:13 2009 +0000
Add a style guideline concerning floating point literals
https://bugs.webkit.org/show_bug.cgi?id=32497
Reviewed by Sam Weinig.
* coding/coding-style.html:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52074 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKitSite/ChangeLog b/WebKitSite/ChangeLog
index 2e07bef..871a2a4 100644
--- a/WebKitSite/ChangeLog
+++ b/WebKitSite/ChangeLog
@@ -1,3 +1,12 @@
+2009-12-13 Dan Bernstein <mitz at apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Add a style guideline concerning floating point literals
+ https://bugs.webkit.org/show_bug.cgi?id=32497
+
+ * coding/coding-style.html:
+
2009-12-09 Marwan Al Jubeh <marwan.aljubeh at gmail.com>
Reviewed by Adam Roben.
diff --git a/WebKitSite/coding/coding-style.html b/WebKitSite/coding/coding-style.html
index 7e5e61b..abd1b72 100644
--- a/WebKitSite/coding/coding-style.html
+++ b/WebKitSite/coding/coding-style.html
@@ -423,6 +423,44 @@ if (count == 0)
<li>In Objective-C, instance variables are initialized to zero automatically. Don't add explicit initializations to nil or NO in an init method.</li>
</ol>
+<h3>Floating point literals</h3>
+<ol>
+<li>Unless required in order to force floating point math, do not append
+<code>.0</code>, <code>.f</code> and <code>.0f</code> to floating point
+literals.
+
+<h4 class="right">Right:</h4>
+<pre class="code">
+const double duration = 60;
+
+void setDiameter(float diameter)
+{
+ radius = diameter / 2;
+}
+
+setDiameter(10);
+
+const int framesPerSecond = 12;
+double frameDuration = 1.0 / framesPerSecond;
+</pre>
+
+<h4 class="wrong">Wrong:</h4>
+<pre class="code">
+const double duration = 60.0;
+
+void setDiameter(float diameter)
+{
+ radius = diameter / 2.f;
+}
+
+setDiameter(10.f);
+
+const int framesPerSecond = 12;
+double frameDuration = 1 / framesPerSecond; // integer division
+</pre>
+</li>
+</ol>
+
<h3>Names</h3>
<ol>
<li>Use CamelCase. Capitalize the first letter, including all letters in an acronym, in a class, struct, protocol, or namespace name. Lower-case the first letter, including all letters in an acronym, in a variable or function name.
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list