Difference between revisions of "Lua:doubleToByteTable"
Jump to navigation
Jump to search
m (moved doubleToByteTable to Lua:doubleToByteTable) |
m |
||
Line 1: | Line 1: | ||
[[Category:Lua]] | [[Category:Lua]] | ||
− | '''function''' doubleToByteTable(''Number'') ''':''' | + | '''function''' doubleToByteTable(''Number'') ''':''' Table |
− | Converts a | + | Converts a double precision (64-bit) floating point number to a table of bytes. |
− | + | ===Function Parameters=== | |
− | === Function Parameters === | + | {|width="85%" cellpadding="10%" cellspacing="0" border="0" |
− | {|width="85%" cellpadding="10 | ||
!align="left"|Parameter | !align="left"|Parameter | ||
!align="left"|Type | !align="left"|Type | ||
Line 12: | Line 11: | ||
|- | |- | ||
|Number | |Number | ||
− | | | + | |Number |
− | |The | + | |The double precision floating point value to convert. |
|} | |} | ||
+ | ===Returns=== | ||
+ | Table — A table containing the bytes representing the double. | ||
− | == Examples == | + | ===Examples=== |
− | + | <pre> | |
− | + | local bytes = doubleToByteTable(3.1415926535) | |
− | + | for i, b in ipairs(bytes) do | |
− | + | print(string.format("Byte %d: %02X", i, b)) | |
− | + | end | |
− | + | -- Output: 8 bytes representing the double in little-endian order | |
− | + | </pre> | |
− | |||
− | |||
− | |||
− | Output: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
{{LuaSeeAlso}} | {{LuaSeeAlso}} |
Revision as of 17:26, 11 July 2025
function doubleToByteTable(Number) : Table
Converts a double precision (64-bit) floating point number to a table of bytes.
Function Parameters
Parameter | Type | Description |
---|---|---|
Number | Number | The double precision floating point value to convert. |
Returns
Table — A table containing the bytes representing the double.
Examples
local bytes = doubleToByteTable(3.1415926535) for i, b in ipairs(bytes) do print(string.format("Byte %d: %02X", i, b)) end -- Output: 8 bytes representing the double in 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