Post Reply 
Base Conversion
08-16-2018, 12:19 PM (This post was last modified: 08-16-2018 12:20 PM by Stevetuc.)
Post: #25
RE: Base Conversion
(08-16-2018 11:43 AM)JDW Wrote:  
(08-16-2018 11:21 AM)Stevetuc Wrote:  Of course the best constructive criticism would be for you to write an "extremely useful" program and post it here. I look forward to it!

Indeed. That would be a program that mimics what I see on my 28S, 48GX and 50g when it comes to base conversion and manipulations like AND, OR and XOR. On my 28S, for example, I need only press the red button, then the B key for Binary and that's where the magic happens. I want it to be that easy on the Prime.


Until we have your program and in the interest of clarity, so others are aware, baseconv WILL convert between ANY base and also easily handles manipulations such as AND, OR and XOR:

eg. Baseconv(#FEh XOR #11101b) converted to decimal #227d


Heres the code again to bring the thread back on topic
Code:

EXPORT Baseconv(in)
BEGIN
LOCAL base,bits,sign;
CHOOSE(base, "Base", "System", "Binary","Octal","Decimal","Hex");
CHOOSE(bits, "Size","System","Input","8","16","32","64");
IF bits >2 THEN CHOOSE(sign, "Sign","Unsigned","Signed") END;
//IF LEFT(STRING(in),1) ≠ "#" THEN in:=EXPR("#"+in+"d") END; //correct the format - no longer needed
CASE
IF bits=1 THEN bits:=GETBITS(#) END //use system bitw
IF bits=2 THEN bits:=GETBITS(in) END //use input bitw
DEFAULT bits:=2^(bits)
END;
IF sign=2 THEN bits:=1-bits END;
SETBITS(SETBASE(in,base-1),bits); 
//R→B(B→R(in),bits,base-1) //old command
END;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Base Conversion - Stevetuc - 05-12-2016, 06:46 AM
RE: Base Conversion - jrozsas - 05-12-2016, 09:21 AM
RE: Base Conversion - salvomic - 05-12-2016, 09:55 AM
RE: Base Conversion - jrozsas - 05-12-2016, 01:10 PM
RE: Base Conversion - salvomic - 05-12-2016, 01:13 PM
RE: Base Conversion - Stevetuc - 05-12-2016, 02:11 PM
RE: Base Conversion - salvomic - 05-12-2016, 02:27 PM
RE: Base Conversion - Stevetuc - 05-12-2016, 04:42 PM
RE: Base Conversion - salvomic - 05-12-2016, 04:52 PM
RE: Base Conversion - Stevetuc - 05-12-2016, 06:49 PM
RE: Base Conversion - salvomic - 05-12-2016, 07:12 PM
RE: Base Conversion - Stevetuc - 05-12-2016, 07:26 PM
RE: Base Conversion - salvomic - 05-12-2016, 07:31 PM
RE: Base Conversion - Eddie W. Shore - 06-07-2016, 01:08 PM
RE: Base Conversion - Stevetuc - 06-09-2016, 03:22 PM
RE: Base Conversion - salvomic - 06-09-2016, 03:33 PM
RE: Base Conversion - Stevetuc - 06-10-2016, 09:19 AM
RE: Base Conversion - JDW - 08-16-2018, 03:56 AM
RE: Base Conversion - Tyann - 08-16-2018, 05:36 AM
RE: Base Conversion - JDW - 08-16-2018, 10:02 AM
RE: Base Conversion - Stevetuc - 08-16-2018, 11:21 AM
RE: Base Conversion - JDW - 08-16-2018, 11:43 AM
RE: Base Conversion - Stevetuc - 08-16-2018 12:19 PM
RE: Base Conversion - JDW - 08-17-2018, 01:46 AM
RE: Base Conversion - Stevetuc - 08-17-2018, 04:13 AM
RE: Base Conversion - salvomic - 06-10-2016, 09:51 AM
RE: Base Conversion - Stevetuc - 06-11-2016, 07:53 AM



User(s) browsing this thread: 1 Guest(s)