changed:
authorClaus Gittinger <cg@exept.de>
Sun, 18 Apr 2010 14:14:41 +0200
changeset 2443 e64a7f2f3fb4
parent 2442 db061ff41012
child 2444 6c4c6addc97a
changed: #examples #initializeConversions
UnitConverter.st
--- a/UnitConverter.st	Mon Apr 12 14:53:03 2010 +0200
+++ b/UnitConverter.st	Sun Apr 18 14:14:41 2010 +0200
@@ -221,6 +221,17 @@
         Transcript showCR:
             (UnitConverter convert:1 from:#'a4H' to:#inch)   
                                                                 [exEnd]
+
+    the mass of a proton:
+                                                                [exBegin]
+        Transcript showCR:
+            (UnitConverter convert:1 from:#'proton' to:#eV)    
+                                                                [exEnd]
+    the energy of a single proton in the LHC (as of 2010)
+                                                                [exBegin]
+        Transcript showCR:
+            (UnitConverter convert:7 from:#'TeV' to:#joule)   
+                                                                [exEnd]
 "
 ! !
 
@@ -238,6 +249,7 @@
     "/ ---------- velocity -------------
 
     Constants at:#lightspeed   put:#(2.997925E8   #'m/s').
+    Constants at:#soundspeed   put:#(343          #'m/s').  "/ 20degC - AIR
 
 
     "/ -------------- length -------------
@@ -330,6 +342,8 @@
     self addConversion:453.59237 from:#lb    to:#gram.
     self addConversion:205       from:#carat to:#milligram.
 
+    self addConversion:0.94      from:#proton to:#GeV.
+
     Aliases at:#oz put:#ounce.
     Aliases at:#lbs put:#lb.
 
@@ -343,10 +357,15 @@
     Aliases at:#joule   put:#'nt*m'.
     Aliases at:#J       put:#'joule'.
     Aliases at:#N       put:#'newton'.
+    Aliases at:#eV      put:#'electronvolt'.
+    Aliases at:#MeV     put:#'megaeV'.
+    Aliases at:#GeV     put:#'gigaeV'.
+    Aliases at:#TeV     put:#'teraeV'.
 
     Aliases at:#watt    put:#'J/s'.
 
     self addConversion:4.1868 from:#calorie  to:#joule.
+    self addConversion:1.60217653E-19 from:#electronvolt  to:#joule.
 
 
     "/ ---------------- cooking ---------------- 
@@ -358,7 +377,7 @@
     "/ ---------------- temperature ---------------- 
 
     self addConversion:[:d | d * 1.8 + 32] from:#celsius    to:#fahrenheit.
-    self addConversion:[:f | f - 32 / 1.8] from:#fahrenheit to:#celsius.
+    self addConversion:[:f | (f - 32) / 1.8] from:#fahrenheit to:#celsius.
 
     "
      Conversions := nil.
@@ -993,9 +1012,9 @@
 !UnitConverter class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/UnitConverter.st,v 1.36 2009-10-27 12:19:01 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/UnitConverter.st,v 1.37 2010-04-18 12:14:41 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic2/UnitConverter.st,v 1.36 2009-10-27 12:19:01 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/UnitConverter.st,v 1.37 2010-04-18 12:14:41 cg Exp $'
 ! !