This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revision Both sides next revision | ||
other:python:misc_by_jyp [2023/05/04 09:46] jypeter [Data representation] Added the Base notions section |
other:python:misc_by_jyp [2023/05/04 11:19] jypeter [Base notions] |
||
---|---|---|---|
Line 476: | Line 476: | ||
* 1 byte <=> 8 bits | * 1 byte <=> 8 bits | ||
* ''REAL*4'' <=> 4 bytes <=> 32 bits | * ''REAL*4'' <=> 4 bytes <=> 32 bits | ||
- | * For easier written/displayed representation, 1 byte is usually split into 2 groups of 4 bits, using base 16 and [[https://en.wikipedia.org/wiki/Hexadecimal|hexadecimal representation]] | + | * For easier written/displayed representation, 1 byte is usually split into 2 groups of 4 bits, and displayed using base 16 and [[https://en.wikipedia.org/wiki/Hexadecimal|hexadecimal representation]] (characters ''0'', ''1'', ..., ''A'', ''B'', ..., ''F'') |
- | * ''0000'' <=> ''0'', ''0010'' <=> ''1'', ..., ''1111'' <=> ''F'' | + | * ''0000'' <=> ''0'',\\ ''0010'' <=> ''1'', ...,\\ ''1111'' <=> ''F'' |
* ''1101'' <=> ''D'' in hexadecimal <=> ''13'' in decimal (''**1** * 8 + **1** * 4 + **0** * 2 + **1** * 1'') | * ''1101'' <=> ''D'' in hexadecimal <=> ''13'' in decimal (''**1** * 8 + **1** * 4 + **0** * 2 + **1** * 1'') | ||
- | * ''11111101'' <=> ''1111 1101'' <=> ''FC'' in hexadecimal <=> ''253'' in decimal (''15 * 16 + 13'') | + | * ''11111101'' <=> ''1111 1101'' <=> ''FD'' in hexadecimal <=> ''253'' in decimal (''15 * 16 + 13'') |
* Conversion with Python | * Conversion with Python | ||
* <code>>>> hex(13) # Decimal to Hexadecimal conversion | * <code>>>> hex(13) # Decimal to Hexadecimal conversion | ||
'0xd' | '0xd' | ||
- | >>> hex(255) | + | >>> hex(253) |
- | '0xff' | + | '0xfd' |
>>> hex(256) | >>> hex(256) | ||
'0x100' | '0x100' |