17bii unit conversions



#2

Has anybody found any clever solver tricks for the 17bii that allow making unit converters that work like on the 19bii? By that I mean, store your input unit, then solve for any desired output unit. I'm sure there are plenty of L(), G(), and S() tricks I haven't fully explored yet.


#3

Here's one from about six months ago.


#4

Thanks Don!

#5

That looks pretty close to the technique I've used before, but it looks like it's limited to converting between mm and in, or m and ft, or km and mi. So there's no way to go from, say, in to km.

I'd like to get as close to the 19bii unit converter as possible, so you could enter any one of mm, in, m, ft, km, or mi, and then solve for any one of the remaining five.

I've got an idea that I think I'll tinker with on my 200LX, since that's a bit easier for typing out long formulas.


#6

Dave, I think I see what you want. It may be possible, but you will have to check and see which value was entered so you can convert from that to what you want, and if you do a conversion after that there will be two values already present, so you'll have to figure out what to do in that situation (maybe that's OK, just convert from either of the two).

I'll play with this tonight when I get home.


#7

This is what I tried so far (on my 200LX, so the syntax and formatting will be a tiny bit different). It doesn't seem to behave as desired, though.

L(val:IF(S(mm):mm/10:0)+IF(S(m):m*100:0)+IF(S(cm):cm:0))=IF(i=1:cm:L(cm:val)*L(i:1))

The idea would be to do Clear Data, store the value into the appropriate starting unit, then immediately solve for that unit. That will convert it to cm and store that value in cm. (The variable i is used to indicate if the solver has been initialized.) Then you would be able to pick any of the other units in the formula, and it will convert them from cm.

I suspect something is going wrong with setting val on the left side, and stuffing it into cm on the right side. When I clear the solver, store a value into mm, and solve for mm, it just zeros out mm, cm, and val, and sets i to 1. If I remove '*L(i:1)' from the right side to prevent initializing i, it initializes cm properly, but then you can't solve for the other units.


#8

Dave, this would be my approach. I only took it as far as 3 units: IN, FT, and MI, but it could be extended to include the other three units as well. You would have to Clear Data between calculations:

IF(S(IN):
IF(FT>0:FTx12:IF(MI>0:MIx63360:0))-IN
:IF(S(FT):
IF(IN>0:IN/12:IF(MI>0:MIx5280:0))-FT
:IF(IN>0:IN/63360:IF(FT>0:FT/5280:0))-MI
)
)

#9

This almost works, but it seems to behave unpredictably (at least on my 200LX):

L(val:IF(S(mm):mm/10:0)+IF(S(m):m*100:0)+IF(S(cm):cm:0))=IF(i=0:L(i:val):i)

The idea is to load 'val' with whatever value is in the variable being solved for, and then if 'i' is zero (i.e. it's the first "run"), load 'val' into 'i'. Subsequent runs then use this value that was stored in 'i' (which in this case, would be the length normalized to cm). This actually seems to be working most of the time.

But for some reason, if I do Clear Data, I can't reinitialize using the same variable/unit I just solved for. It'll just zero it out. The sequence looks something like this:

18
[mm]
"mm = 18"
[mm]
"mm = 18" ('i' gets set here)
[cm]
"cm = 1.8"
[Clear Data]
15
[cm]
"cm = 15"
[cm]
"cm = 0" ('i' stays at zero)

Not totally sure what's going on here. I'll have to try it on my 17bii and 19bii tonight.


#10

Dave, I entered your equation on my 17bii and got these results:

clear data
18
mm
"mm = 18"
mm
"mm = 0"
cm
"cm = 0"

You are blazing new territory here. I have to admit I don't understand exactly what your equation is doing. I haven't tried it on my 19b but I expect the results would be the same.


#11

Yeah, just tried it on my 19bii and 17bii. Didn't work on either of them. The variables 'val' and 'i' never get set. Back to the drawing board.

#12

Hi Dave & Don,

This is a very interesting solve problem. Looks simple, but is a lot deeper than it looks. My first few tries were trying to enter FEET into FT and then press a second time, but no matter what I tried, the solver would always zero feet out.

The work around was to use a dummy variable X. The following listing is from the CPACK200 program, but should work on a real HP-17BII.

{IF (S(MILE):
0*FT+
0*IN*
0*KM+
0*M+
0*X+
MILE-G(X)+
0*L(FT:MILE*5280)+
0* L( IN:FT* 12) +
0* L( KM:MILE*1.60934)+
0*L(M:MILE*1609.34):
IF (S(FT):
FT-G(X)+
0*L(MILE:FT/5280)+
0*L(IN:FT*12)+
0*L(KM:FT/3280.8)+
0*L(M:FT/3.2808):0))
}


Takes two steps to do a conversion:

To convert Miles to FT, IN, KM, and M, enter the miles into X and then press MILES key to do the conversion. Results are in each of the variables.

Likewise for Inches, enter inches into X and then press IN key.

The routine could be expanded to do the remaining units.

Bill


#13

Hmm, interesting, if a bit "wordy". I'll have to play with that and see if there's a way to do it without entering the conversion factors twice. I have an idea, but it might be too crazy to work (like my last attempt). :)


#14

Alright, this works on my 19bii, but there are two problems with it.

1. It's kind of slow.

2. It's completely insane.

I'll try to add some C-style inline comments, since it's not obvious what's going on here.

//Throwaway values (all the L() magic happens in here).
0*(
//Store the proper conversion factor in F, and temp CM value in V
L(V:
IF(S(MM):G(MM)*L(F:.1):0)
+IF(S(M):G(M)*L(F:100):0)
+IF(S(CM):G(CM)*L(F:1):0)
)
//Put value from V into CM on first run
+IF(G(CM)=0:L(CM:G(V)):0)
)
//Choose the correct equation based on what variable to solve for.
//Moving the -G(CM) outside the IF breaks it for some reason.
+IF(S(M):M*G(F)-G(CM):0)
+IF(S(CM):CM*G(F)-G(CM):0)
+IF(S(MM):MM*G(F)-G(CM):0)

But it works! All you do is Clear Data, store your starting unit, then immediately solve for that same unit. You'll get the same value back. Then if you solve for any other variable, you'll get the amount converted to that unit.


Possibly Related Threads…
Thread Author Replies Views Last Post
  17BII & 17BII+ Discounted Payback Period Revisited Tom Neudorfl 8 2,935 11-25-2013, 10:28 AM
Last Post: Don Shepherd
  Interesting Base Conversions - Porting a 1975 HP 25 Program to the HP 35S Eddie W. Shore 1 1,366 10-13-2013, 07:49 PM
Last Post: BruceH
  Unit circle on HP Prime Mic 2 1,348 08-28-2013, 05:22 PM
Last Post: Thomas Klemm
  Decimal/Binary Conversions for the HP 39gii - 3/16/2013 Eddie W. Shore 0 948 03-16-2013, 04:30 PM
Last Post: Eddie W. Shore
  Unit conversions inside programs on 50g Chris Smith 2 1,283 02-23-2013, 05:35 AM
Last Post: Chris Smith
  WP 34S adding own conversions Lourensk 4 1,577 03-24-2012, 02:45 PM
Last Post: Walter B
  Re: Voyager 1xC emulation in the same unit? uhmgawa 4 2,179 01-24-2012, 01:09 AM
Last Post: uhmgawa
  Dave Ramsey et al with early HP 41C conversions to CL Geoff Quickfall 4 1,853 01-01-2012, 12:51 AM
Last Post: David Ramsey
  Google onlinecalculator conversions etc. designnut 2 1,142 08-18-2011, 09:23 AM
Last Post: snaggs
  Wp34s unit conversions Cristian Arezzini 4 1,589 07-25-2011, 05:02 AM
Last Post: Paul Dale

Forum Jump: