--- a/UnitConverter.st Sat Dec 28 15:53:06 2002 +0100
+++ b/UnitConverter.st Thu Jan 09 18:16:59 2003 +0100
@@ -219,29 +219,12 @@
initializeConversions
"initialize common conversions"
- Scaling := IdentityDictionary new.
+ self initializeScaleFactors.
+
Conversions := IdentityDictionary new.
Aliases := IdentityDictionary new.
Constants := IdentityDictionary new.
- Scaling at:#exa put:1000000000000000000.
- Scaling at:#peta put:1000000000000000.
- Scaling at:#tera put:1000000000000.
- Scaling at:#giga put:1000000000.
- Scaling at:#mega put:1000000.
- Scaling at:#myria put:10000.
- Scaling at:#kilo put:1000.
- Scaling at:#hecto put:100.
- Scaling at:#deci put:(1/10).
- Scaling at:#centi put:(1/100).
- Scaling at:#milli put:(1/1000).
- Scaling at:#micro put:(1/1000000).
- Scaling at:#nano put:(1/1000000000).
- Scaling at:#pico put:(1/1000000000000).
- Scaling at:#femto put:(1/1000000000000000).
- Scaling at:#atto put:(1/1000000000000000000).
-
-
"/ ---------- velocity -------------
Constants at:#lightspeed put:#(2.997925E8 #'m/s').
@@ -289,7 +272,88 @@
"/ ---------- printing -------------
+ self initializePrintValues.
+ "/ ---------------- area -------------------
+
+ "/ US
+ self addConversion:4840 from:#acre to:#'yard^2'.
+
+ self addConversion:100 from:#are to:#'meter^2'.
+ self addConversion:100 from:#hectare to:#are.
+
+ "/ german area - add your countries, and return to me ...
+ Aliases at:#'german-ar' put:#are.
+ Aliases at:#'german-hektar' put:#hectare.
+
+
+ "/ ---------------- liquid ----------------
+
+ self addConversion:231 from:#gallon to:#'inch^3'.
+ self addConversion:(1/4) from:#quart to:#gallon. "/ well - at least here,
+ "/ thats also 1/4th of a good wine ;-)
+ self addConversion:(1/2) from:#pint to:#quart.
+ self addConversion:(1/16) from:#floz to:#pint.
+ self addConversion:(1/8) from:#fldr to:#floz.
+
+ self addConversion:42 from:#barrel to:#gallon.
+ self addConversion:35.23907 from:#bushel to:#liter.
+
+ Aliases at:#cc put:#'cm^3'.
+ Aliases at:#liter put:#kilocc.
+ Aliases at:#ml put:#milliliter.
+ Aliases at:#gal put:#gallon.
+ Aliases at:#qt put:#quart.
+
+
+ "/ ---------------- mass ----------------
+
+ self addConversion:28.35 from:#ounce to:#gram.
+ self addConversion:453.59237 from:#lb to:#gram.
+ self addConversion:205 from:#carat to:#milligram.
+
+ Aliases at:#oz put:#ounce.
+ Aliases at:#lbs put:#lb.
+
+ Aliases at:#gm put:#gram.
+ Aliases at:#kg put:#kilogram.
+
+ "/ well, a pint of beer is not always:
+ self addConversion:277.420 from:#'british-gallon' to:#'inch^3'.
+ self addConversion:(1/4) from:#'british-quart' to:#'british-gallon'.
+ self addConversion:(1/2) from:#'british-pint' to:#'british-quart'.
+ self addConversion:(1/16) from:#'british-floz' to:#'british-pint'.
+
+ "/ ---------------- energy ----------------
+
+ Aliases at:#cal put:#calorie.
+ Aliases at:#nt put:#newton.
+ Aliases at:#joule put:#'nt*m'.
+
+ self addConversion:4.1868 from:#calorie to:#joule.
+
+
+ "/ ---------------- cooking ----------------
+
+ self addConversion:4 from:#tablespoon to:#fldr.
+ self addConversion:(4/3) from:#teaspoon to:#fldr.
+
+
+ "/ ---------------- temperature ----------------
+
+ self addConversion:[:d | d * 1.8 + 32] from:#celsius to:#fahrenheit.
+ self addConversion:[:f | f - 32 / 1.8] from:#fahrenheit to:#celsius.
+
+ "
+ Conversions := nil.
+ UnitConverter initializeConversions
+ "
+
+ "Created: / 22.7.1997 / 13:56:40 / cg"
+ "Modified: / 10.10.2001 / 14:39:04 / cg"
+!
+
+initializePrintValues
"/ inch to (roughly) a typesetter point
self addConversion:(1/72) from:#point to:#inch.
@@ -390,85 +454,27 @@
Aliases at:#a6lH put:#'a6-landscape-page-height'.
Aliases at:#b5lW put:#'b5-landscape-page-width'.
Aliases at:#b5lH put:#'b5-landscape-page-height'.
-
-
- "/ ---------------- area -------------------
-
- "/ US
- self addConversion:4840 from:#acre to:#'yard^2'.
-
- self addConversion:100 from:#are to:#'meter^2'.
- self addConversion:100 from:#hectare to:#are.
-
- "/ german area - add your countries, and return to me ...
- Aliases at:#'german-ar' put:#are.
- Aliases at:#'german-hektar' put:#hectare.
-
-
- "/ ---------------- liquid ----------------
+!
- self addConversion:231 from:#gallon to:#'inch^3'.
- self addConversion:(1/4) from:#quart to:#gallon. "/ well - at least here,
- "/ thats also 1/4th of a good wine ;-)
- self addConversion:(1/2) from:#pint to:#quart.
- self addConversion:(1/16) from:#floz to:#pint.
- self addConversion:(1/8) from:#fldr to:#floz.
-
- self addConversion:42 from:#barrel to:#gallon.
- self addConversion:35.23907 from:#bushel to:#liter.
-
- Aliases at:#cc put:#'cm^3'.
- Aliases at:#liter put:#kilocc.
- Aliases at:#ml put:#milliliter.
- Aliases at:#gal put:#gallon.
- Aliases at:#qt put:#quart.
-
-
- "/ ---------------- mass ----------------
-
- self addConversion:28.35 from:#ounce to:#gram.
- self addConversion:453.59237 from:#lb to:#gram.
- self addConversion:205 from:#carat to:#milligram.
+initializeScaleFactors
+ Scaling := IdentityDictionary new.
- Aliases at:#oz put:#ounce.
- Aliases at:#lbs put:#lb.
-
- Aliases at:#gm put:#gram.
- Aliases at:#kg put:#kilogram.
-
- "/ well, a pint of beer is not always:
- self addConversion:277.420 from:#'british-gallon' to:#'inch^3'.
- self addConversion:(1/4) from:#'british-quart' to:#'british-gallon'.
- self addConversion:(1/2) from:#'british-pint' to:#'british-quart'.
- self addConversion:(1/16) from:#'british-floz' to:#'british-pint'.
-
- "/ ---------------- energy ----------------
-
- Aliases at:#cal put:#calorie.
- Aliases at:#nt put:#newton.
- Aliases at:#joule put:#'nt*m'.
-
- self addConversion:4.1868 from:#calorie to:#joule.
-
-
- "/ ---------------- cooking ----------------
-
- self addConversion:4 from:#tablespoon to:#fldr.
- self addConversion:(4/3) from:#teaspoon to:#fldr.
-
-
- "/ ---------------- temperature ----------------
-
- self addConversion:[:d | d * 1.8 + 32] from:#celsius to:#fahrenheit.
- self addConversion:[:f | f - 32 / 1.8] from:#fahrenheit to:#celsius.
-
- "
- Conversions := nil.
- UnitConverter initializeConversions
- "
-
- "Created: / 22.7.1997 / 13:56:40 / cg"
- "Modified: / 10.10.2001 / 14:39:04 / cg"
+ Scaling at:#exa put:1000000000000000000.
+ Scaling at:#peta put:1000000000000000.
+ Scaling at:#tera put:1000000000000.
+ Scaling at:#giga put:1000000000.
+ Scaling at:#mega put:1000000.
+ Scaling at:#myria put:10000.
+ Scaling at:#kilo put:1000.
+ Scaling at:#hecto put:100.
+ Scaling at:#deci put:(1/10).
+ Scaling at:#centi put:(1/100).
+ Scaling at:#milli put:(1/1000).
+ Scaling at:#micro put:(1/1000000).
+ Scaling at:#nano put:(1/1000000000).
+ Scaling at:#pico put:(1/1000000000000).
+ Scaling at:#femto put:(1/1000000000000000).
+ Scaling at:#atto put:(1/1000000000000000000).
! !
!UnitConverter class methodsFor:'accessing'!
@@ -904,5 +910,5 @@
!UnitConverter class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic2/UnitConverter.st,v 1.22 2002-12-20 14:59:55 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic2/UnitConverter.st,v 1.23 2003-01-09 17:16:59 cg Exp $'
! !