Replaced JavaScript double-normalization with one liner.
authorManu Sporny <msporny@digitalbazaar.com>
Tue, 01 Feb 2011 17:32:47 -0500
changeset 21 6ae74cb2abaa
parent 20 1f999400e01a
child 22 eeaef41b1beb
Replaced JavaScript double-normalization with one liner.
spec/latest/index.html
--- a/spec/latest/index.html	Tue Feb 01 17:04:16 2011 -0500
+++ b/spec/latest/index.html	Tue Feb 01 17:32:47 2011 -0500
@@ -1764,13 +1764,8 @@
 
 <pre class="example" data-transform="updateExample">
 <!--
-// the double value to convert to a JSON-LD normalized string
-var value = 2.33333333333;
-// Convert the value, producing the equivalent output to printf("%1.6e", value);
-var s = (value).toExponential(6); 
-s = s.substr(0, s.indexOf('e') + 2) + 
-   (s.indexOf('e') == s.length - 3 ? '0' : '') + 
-   s.substr(s.indexOf('e') + 2);
+// the variable 'value' below is the JavaScript native double value that is to be converted
+(value).toExponential(6).replace(/(e(?:\+|-))([0-9])$/, '$10$2')
 -->
 </pre>