Non-decimal radices/Input: Difference between revisions
Content added Content deleted
(→{{header|PARI/GP}}: 2.8.0 note) |
|||
Line 613: | Line 613: | ||
=={{header|PARI/GP}}== |
=={{header|PARI/GP}}== |
||
Binary conversion is built in to PARI/GP, this script can convert from bases2-36 to bases 2-36. I've had help with this script at http:\\mersenneforums.org . The main flaw in this script I see is that it doesn't allow 36^x-1 type strings, I'll have to add that on later. |
Binary conversion is built in to PARI/GP, this script can convert from bases2-36 to bases 2-36. I've had help with this script at http:\\mersenneforums.org . The main flaw in this script I see is that it doesn't allow 36^x-1 type strings, I'll have to add that on later. |
||
⚫ | |||
<lang PARI/GP> |
|||
⚫ | |||
my(B=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],a=0,c=""); |
my(B=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],a=0,c=""); |
||
numb1=Vec(Str(numb1)); |
numb1=Vec(Str(numb1)); |
||
Line 629: | Line 628: | ||
); |
); |
||
c |
c |
||
}; |
};</lang> |
||
</lang> |
|||
Note that version 2.8.0+ supports hexadecimal (0x1ff) and binary (0b10101) inputs. Further, it can accept generic input as a vector: |
|||
{{works with|PARI/GP|2.8.0+}} |
|||
<lang parigp>fromdigits([1,15,15],16)</lang> |
|||
=={{header|Perl}}== |
=={{header|Perl}}== |