- REDIRECT Convert between hex and decimal
(Remove html character entities) |
JohnBeckett (Talk | contribs) (merged to 27) |
||
| Line 1: | Line 1: | ||
| − | {{review}} |
+ | #REDIRECT [[Convert between hex and decimal]] |
| − | {{TipImported |
||
| − | |id=772 |
||
| − | |previous=771 |
||
| − | |next=773 |
||
| − | |created=August 18, 2004 |
||
| − | |complexity=basic |
||
| − | |author=Thomas Ramming |
||
| − | |version=6.0 |
||
| − | |rating=3/4 |
||
| − | |category1= |
||
| − | |category2= |
||
| − | }} |
||
| − | Here is a quick way to transform hex numbers to decimal or vice versa. |
||
| − | |||
| − | Visual select the number (no leading '0x' allowed, sorry) and select the menu to transform the number. |
||
| − | |||
| − | You need the calculator 'bc' (standard unix, or cygwin). |
||
| − | |||
| − | UNIX: |
||
| − | |||
| − | <pre> |
||
| − | vmenu 1.220 PopUp.&nr2hex <Esc>:exec("!echo \\"obase=16;".@*."\\" \| bc -l -q ")<CR> |
||
| − | vmenu 1.220 PopUp.hex&2nr <Esc>:exec("!echo \\"ibase=16;".toupper(@*)."\\" \| bc -l -q ")<CR> |
||
| − | </pre> |
||
| − | |||
| − | Windows (need something like): |
||
| − | |||
| − | <pre> |
||
| − | <Esc>:!bash -c " <see exec(...) above plus extra escaping> "<CR> |
||
| − | </pre> |
||
| − | |||
| − | ==Comments== |
||
| − | Use {{script|id=54}} to have a more general solution without using an external program like bc. |
||
| − | |||
| − | ---- |
||
| − | Script 54 is just a transformation of numbers, bc can really calculate, work with variables, functions etc. |
||
| − | |||
| − | So what is FAB1DF4 * FF |
||
| − | |||
| − | Just visual mark 'FAB1DF4 * FF' and select 'hex2nr' to see the result. |
||
| − | |||
| − | <pre> |
||
| − | FAB1DF4 * FF = 67032503820 |
||
| − | 262872564 * 255 = 67032503820 |
||
| − | </pre> |
||
| − | |||
| − | ---- |
||
| − | Also see [[VimTip448]]. |
||
| − | |||
| − | ---- |
||