50G custom units conversions
|
09-09-2014, 06:49 AM
Post: #6
|
|||
|
|||
RE: 50G custom units conversions
(09-08-2014 11:40 PM)CosmicTruth Wrote: ... so can you show me a little code to just change between 2 units using custom units? ... I will try my very best! Let's take the money conversion from the Harry Potter universe: The wizards use a strange system of Galleons, Sickles, and Knuts, whereas 1 Galleon = 17 Sickles 1 Sickle = 29 Knuts (thus 1 Galleon = 493 Knuts) BTW, the relation to the "real" world is given by 1 Galleon ~ £5, thus 1 Knut ~ 1 Penny. You would implement this as follows: Start with a new directory, e.g. Potter, and change into it via keypress of the according softkey in the vars menu: 'Potter' CRDIR Potter Now define the new units creating variables with appropriate name, and value. Lets start with Knuts, which we define via Sickles, knowing that one Knut is 1/29 Sickle: '3.44827586207E-2_Sickles' 'Knuts' STO> Next for Sickles, defined as 1/17 Galleon: '5.88235294118E-2_Galleons' 'Sickles' STO> And for the conversion to real world: '5.0_£' 'Galleons' STO> But finally you have to declare the "basic" unit within this system, otherwise you will get an "Invalid Unit" error. I choose the GBP. This is accomplished the following way: '1_?' '£' STO> It's clear that there may be one and only one basic unit defined. Therefore you need for every unit system it's own directory! To start the conversions, you need finally a special custom menu: { '1_Knuts' '1_Sickles' '1_Galleons' '1_£' } 'CST' STO> And now simply call CUSTOM (left-shift MODE key). After that, you convert the usual way via softkey and left-shift-softkey, e.g. Enter 10 softkey '£', you will have 10_£ on the stack. left-shift softkey Galleons will give 2_Galleons on the stack. left-shift softkey Sickles will give 34_Sickles on the stack. How much is 2 Galleons 4 Sickles 11 Knuts? I omit the word softkey: 2 Galleons 4 Sickles + 11 Knuts + ends up in 1113._Knuts left-shift £ gives ~ 11.29_£ BTW, we see the big advantage of the decimal system. SI prefixes may simply added when needed. So you may key in e.g. 1000 kilo-Knuts: 1000._kKnuts which converts via left-shift £ to ~ 10142_£ Hope that helps, Ralf. |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
50G custom units conversions - CosmicTruth - 09-06-2014, 01:29 AM
RE: 50G custom units conversions - rkf - 09-06-2014, 07:17 PM
RE: 50G custom units conversions - rkf - 09-08-2014, 08:36 AM
RE: 50G custom units conversions - CosmicTruth - 09-07-2014, 02:02 AM
RE: 50G custom units conversions - CosmicTruth - 09-08-2014, 11:40 PM
RE: 50G custom units conversions - rkf - 09-09-2014 06:49 AM
RE: 50G custom units conversions - CosmicTruth - 09-11-2014, 12:43 AM
RE: 50G custom units conversions - CosmicTruth - 09-17-2014, 11:36 AM
RE: 50G custom units conversions - rkf - 09-17-2014, 11:57 AM
|
User(s) browsing this thread: 1 Guest(s)