Difference between revisions of "Lua:dwordToByteTable"
Jump to navigation
Jump to search
m (moved dwordToByteTable to Lua:dwordToByteTable) |
m |
||
Line 1: | Line 1: | ||
[[Category:Lua]] | [[Category:Lua]] | ||
− | '''function''' dwordToByteTable(''Number'') ''':''' | + | '''function''' dwordToByteTable(''Number'') ''':''' Table |
− | Converts a | + | Converts a 32-bit dword (integer) to a table of bytes. |
− | + | ===Function Parameters=== | |
− | + | {|width="85%" cellpadding="10%" cellspacing="0" border="0" | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | === Function Parameters === | ||
− | {|width="85%" cellpadding="10 | ||
!align="left"|Parameter | !align="left"|Parameter | ||
!align="left"|Type | !align="left"|Type | ||
Line 24: | Line 11: | ||
|- | |- | ||
|Number | |Number | ||
− | | | + | |Integer |
− | |The | + | |The 32-bit dword to convert. |
|} | |} | ||
+ | ===Returns=== | ||
+ | Table — A table containing the bytes representing the dword. | ||
− | == Examples == | + | ===Examples=== |
− | + | <pre> | |
− | + | local bytes = dwordToByteTable(0x12345678) | |
− | + | for i, b in ipairs(bytes) do | |
− | + | print(string.format("Byte %d: %02X", i, b)) | |
− | + | end | |
− | + | -- Output: Byte 1: 78, Byte 2: 56, Byte 3: 34, Byte 4: 12 (little-endian order) | |
− | + | </pre> | |
− | |||
− | |||
− | |||
− | |||
− | Output: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
{{LuaSeeAlso}} | {{LuaSeeAlso}} |
Revision as of 17:24, 11 July 2025
function dwordToByteTable(Number) : Table
Converts a 32-bit dword (integer) to a table of bytes.
Function Parameters
Parameter | Type | Description |
---|---|---|
Number | Integer | The 32-bit dword to convert. |
Returns
Table — A table containing the bytes representing the dword.
Examples
local bytes = dwordToByteTable(0x12345678) for i, b in ipairs(bytes) do print(string.format("Byte %d: %02X", i, b)) end -- Output: Byte 1: 78, Byte 2: 56, Byte 3: 34, Byte 4: 12 (little-endian order)
See also
Related Functions
- readBytes
- readSmallInteger
- readInteger
- readQword
- readPointer
- readFloat
- readDouble
- readString
- writeBytes
- writeSmallInteger
- writeInteger
- writeQword
- writeFloat
- writeDouble
- writeString
- readBytesLocal
- readIntegerLocal
- readQwordLocal
- readPointerLocal
- readFloatLocal
- readDoubleLocal
- readStringLocal
- writeBytesLocal
- writeIntegerLocal
- writeQwordLocal
- writeFloatLocal
- writeDoubleLocal
- writeStringLocal
- wordToByteTable
- dwordToByteTable
- qwordToByteTable
- floatToByteTable
- doubleToByteTable
- stringToByteTable
- wideStringToByteTable
- byteTableToWord
- byteTableToDword
- byteTableToQword
- byteTableToFloat
- byteTableToDouble
- byteTableToString
- byteTableToWideString