I cant remember how I did it on the 50g - Printable Version +- HP Forums (https://archived.hpcalc.org/museumforum) +-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html) +--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html) +--- Thread: I cant remember how I did it on the 50g (/thread-128082.html) I cant remember how I did it on the 50g - Ken Ratkevich - 11-07-2007 Hi, I know. The manuals refer to integer manipulation only of non-base 10 numbers. BUT, I remember I found a quick way to convert #.011b to #.375d (or vice-versa). I remember because I thought to myself at the time that "I'll have to remember this". But it's final time (home study) and I forgot. Any Ideas? As always - THANKS, Ken Re: I cant remember how I did it on the 50g - Chuck Sommer - 11-07-2007 Put the calculator in BASE mode (Orange_shift BASE (over the 3)). Then the Fx keys can switch between the 4 different display formats Hex(F1), Dec(F2), Oct(F3) and Bin(F4). This will change the display of all numbers that are displayed with #xxxxxb. Re: I cant remember how I did it on the 50g - Hal Bitton in Boise - 11-07-2007 Hi again Ken, This method will work, although it can get a bit tedious... To convert from a binary fraction to a decimal fraction: Let's use your example of #.011b: Multiply the binary fractional number by the power of 2 necessary to move the point to the right of the rightmost digit. In our case we need to move the point three places to the right, so we multiply by 2^3, which gives us #11b. Use the calc to convert this to decimal, which yields 3. Divide this by 2^3 (to remove it) and we get .375 . Going the other way is essentially the reverse of the above, take your decimal fraction and start multiplying by increasing powers of 2 until it's an integer (just start hitting 2 multiply while keeping count)...in our case .375 becomes an integer (3) after being multiplied by 2^3 (8). Convert to binary and divide by 2^3 by sliding the point three places to the left. If your decimal fractional number won't convert to a pure integer by multiplying by increasing powers of two (and most won't), you're looking at a repeating binary fractional number. Carry out the powers of 2 multiplication until you feel you have enough accuracy (2^13 seems like a good place to stop). Example: To convert .6 decimal to binary: .6 ENTER, 2 multiply repeatedly while counting. Stop at 13 reps (2^13). display reads 4915.2. Convert to binary (calc will round off fractional part of number) to get #1001100110011b, divide by 2^13 by sliding point 13 places to the left to get #.1001100110011...b. You could write subroutines to help with the tedious aspects of this, but I'll leave that to you. Best regards, Hal Re: I cant remember how I did it on the 50g - Dave Britten - 11-07-2007 There's nothing built in, but I've got a small program that can do these conversions. It's rather unsophisticated, and does no error checking, so garbage in, garbage out, as they say. It'll handle negative numbers; simply include a minus sign as the first character in your string. Either key the program in manually, or transfer with Kermit in ASCII mode. 3: Source base (Real) 2: Destination base (Real) 1: Number (String) ```%%HP: T(3)A(R)F(.); \<< \<< NUM IF DUP 64. > THEN 55. - ELSE 48. - END \>> \<< IF DUP 9. > THEN 55. + ELSE 48. + END CHR \>> 0. 0. 0. 0. 0. 0. 0. 0. \-> SB DB VS CVAL VALC V L DP R ST EN SG N \<< IF SB 10. == THEN VS OBJ\-> 'V' STO IF V 0. < THEN V NEG 'V' STO -1. 'SG' STO ELSE 1. 'SG' STO END ELSE VS SIZE 'L' STO VS "." POS 'DP' STO IF DP 0. \=/ THEN SB INV 'R' STO DP 1. + L FOR x VS x DUP SUB CVAL EVAL R * V + 'V' STO R SB / 'R' STO NEXT DP 1. - 'ST' STO ELSE L 'ST' STO END 1. 'R' STO IF VS 1. 1. SUB "-" == THEN -1. 'SG' STO 2. 'EN' STO ELSE 1. 'SG' STO 1. 'EN' STO END ST EN FOR x VS x x SUB CVAL EVAL R * V + 'V' STO R SB * 'R' STO -1. STEP END IF SG -1. == THEN "-" 'VS' STO ELSE "" 'VS' STO END V LN DB LN / IP DB SWAP ^ 'R' STO 0. 'DP' STO WHILE V .000000000001 > REPEAT IF R 0. > R 1. < AND DP 0. == AND THEN VS "." + 'VS' STO 1. 'DP' STO END V R / IP 'N' STO VS N VALC EVAL + 'VS' STO N R * V SWAP - 'V' STO R DB / 'R' STO END VS \>> \>> ``` Checksum (from a 48GX): #EA1Eh Re: I cant remember how I did it on the 50g - Ken Ratkevich - 11-08-2007 Hi, The problem with this is the 50g chokes on decimal points for non-decimal numbers. Thanks Re: I cant remember how I did it on the 50g - Ken Ratkevich - 11-08-2007 Hey, how are you? Yeah. This is what I am trying to avoid. It's a supervised exam with a time limit and I really don't wan't to waste time on fractional non-decimal number conversions. Especially when I WILL NEVER need to do this on the job (or elsewhere). Thanks Re: I cant remember how I did it on the 50g - Ken Ratkevich - 11-08-2007 Wow! Not having 50g programming experience it looks sophisticated to me. I'll look in the manual to find out how to feed it to my calc. THANKS FOR THE EFFORT!!! Re: I cant remember how I did it on the 50g - Ken Ratkevich - 11-08-2007 OK. I found the cable. I've got conn4X installed and the USB drivers loaded. I can do print screens to the PC. I've got your program in a text file. What next please?