Decimal floating point number to binary: Difference between revisions
Content added Content deleted
m (→version 1: changed wording and whitespace in the REXX section header.) |
|||
Line 1,102: | Line 1,102: | ||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
===version 1=== |
===version 1=== |
||
This REXX version will handle any number of digits, with bases up to 242 |
This REXX version will handle any number of digits, with bases up to '''242''' |
||
(using extended ASCII characters). |
(using extended ASCII characters). |
||
Bases up to 62 will just use decimal digits along with upper and lowercase |
Bases up to '''62''' will just use decimal digits along with upper and lowercase |
||
(Latin) letters. |
(Latin) letters. |
||
Line 1,114: | Line 1,114: | ||
This program handles numbers with leading signs ('''-''', '''+'''). |
This program handles numbers with leading signs ('''-''', '''+'''). |
||
''Bases'' that are negative are also supported (which won't |
''Bases'' that are ''negative'' are also supported (which won't |
||
be explained here). |
be explained here). |
||
Line 1,127: | Line 1,127: | ||
The number of digits (numerals) in the result may be specified (for |
The number of digits (numerals) in the result may be specified (for |
||
continued fractions). The default is 60. |
continued fractions). The default is '''60'''. |
||
The REXX program can handle any sized number (as per the number of |
The REXX program can handle any sized number (as per the number of |
||
digits)   that can be entered at the command line. |
digits) that can be entered at the command line. |
||
<lang rexx>/*REXX pgm converts any number in a base to another base including fractions; bases≤242.*/ |
<lang rexx>/*REXX pgm converts any number in a base to another base including fractions; bases≤242.*/ |
||
parse arg number toBase inBase digits . /* |
parse arg number toBase inBase digits . /*obtain optional arguments from the CL*/ |
||
if toBase=='' | toBase=="," then toBase=10 /*Not specified? Then use the default.*/ |
if toBase=='' | toBase=="," then toBase=10 /*Not specified? Then use the default.*/ |
||
if inBase=='' | inBase=="," then inBase=10 /* " " " " " " */ |
if inBase=='' | inBase=="," then inBase=10 /* " " " " " " */ |