HP Prime: Base Conversions – Joe Horn
The HP Prime has a CONVERT (upper case letters) that converts units (i.e. length, volume, etc.). However, for the base to work, not only convert has to be typed in lower case letters, AND it is a CAS command.
The syntax that Joe told me is:
Decimal to Other Base (D2B)
convert(number in base 10, base, desired base)
The word base is typed in lowercase. The result is a vector of digits but the order goes from lower power to upper power. The number will be written backwards. To get it in proper order:
REVERSE(convert(number in base 10, base, desired base))
In Home mode or in programming, you will need a CAS command attached to the syntax.
Other Base to Decimal
convert(vector of digits, base, base that is represented)
Again, going this way the vector of digits goes from lower to upper power. The proper order requires the following:
convert(REVERSE(vector of digits), base, base that is represented)
Once again, in Home mode or in programming, you will need a CAS command attached to the syntax.
Below are programs that help accomplish these tasks:
HP Prime Program D2B (decimal to base)
EXPORT D2B(n,b)
BEGIN
// decimal to base
// Joe Horn
CAS("REVERSE(convert(n,base,b))");
END;
Example: D2B(17291, 12) returns [10 0 0 11] (A00B_12)
HP Prime Program B2D (base to decimal)
EXPORT B2D(n,b)
BEGIN
// vector (decr),base to base 10
// Joe Horn
CAS("convert(REVERSE(n),base,b)");
END;
Example: B2D([1, 0, 1, 6, 2, 5], 7) returns 17463. (101625_7)
Thanks you
New Update HP Prime: Base Conversions – Joe Horn
Reviewed by Anonymous
on
18:51
Rating:
No comments: