Difference between revisions of "Lua:byteTableToFloat"
Jump to navigation
Jump to search
m (Added CodeBox Template.) |
|||
| (5 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
| − | '''function''' byteTableToFloat(''Table'') ''':''' | + | [[Category:Lua]] |
| + | {{CodeBox|'''function''' byteTableToFloat(''Table'') ''':''' Number}} | ||
| − | Converts a | + | Converts a table of bytes to a single precision (32-bit) floating point number. |
| − | + | ===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 11: | Line 11: | ||
|- | |- | ||
|Table | |Table | ||
| − | | | + | |Table |
| − | | | + | |A table containing the bytes to convert (least significant byte first). |
|} | |} | ||
| + | ===Returns=== | ||
| + | Number — The resulting single precision floating point value. | ||
| − | == | + | ===Explanation=== |
| − | + | The function takes a table of bytes (e.g., <code>{0xC3, 0xF5, 0x48, 0x40}</code>) and interprets them as a 32-bit float in little-endian order. | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | For example, <code>byteTableToFloat({0xC3, 0xF5, 0x48, 0x40})</code> returns <code>3.14</code>. | |
| − | |||
| − | |||
| + | ===Examples=== | ||
| + | <pre> | ||
| + | local floatValue = byteTableToFloat({0xC3, 0xF5, 0x48, 0x40}) | ||
| + | print(floatValue) -- Output: 3.14 | ||
| + | </pre> | ||
| − | + | {{LuaSeeAlso}} | |
| − | |||
| − | |||
=== Related Functions === | === Related Functions === | ||
| − | + | {{ReadWriteMemory}} | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Latest revision as of 23:12, 4 December 2025
| <> Function function byteTableToFloat(Table) : Number |
Converts a table of bytes to a single precision (32-bit) floating point number.
Function Parameters[edit]
| Parameter | Type | Description |
|---|---|---|
| Table | Table | A table containing the bytes to convert (least significant byte first). |
Returns[edit]
Number — The resulting single precision floating point value.
Explanation[edit]
The function takes a table of bytes (e.g., {0xC3, 0xF5, 0x48, 0x40}) and interprets them as a 32-bit float in little-endian order.
For example, byteTableToFloat({0xC3, 0xF5, 0x48, 0x40}) returns 3.14.
Examples[edit]
local floatValue = byteTableToFloat({0xC3, 0xF5, 0x48, 0x40})
print(floatValue) -- Output: 3.14
See also[edit]
| Lua |
| Script Engine |
Related Functions[edit]
| Read Functions |
|---|
| readBytes |
| readSmallInteger |
| readInteger |
| readQword |
| readPointer |
| readFloat |
| readDouble |
| readString |
| Read Functions (Local Process) |
| readBytesLocal |
| readIntegerLocal |
| readQwordLocal |
| readPointerLocal |
| readFloatLocal |
| readDoubleLocal |
| readStringLocal |
| Write Functions |
| writeBytes |
| writeSmallInteger |
| writeInteger |
| writeQword |
| writeFloat |
| writeDouble |
| writeString |
| Write Functions (Local Process) |
| writeBytesLocal |
| writeIntegerLocal |
| writeQwordLocal |
| writeFloatLocal |
| writeDoubleLocal |
| writeStringLocal |
| Byte Table Conversions (Value → Byte Table) |
| wordToByteTable |
| dwordToByteTable |
| qwordToByteTable |
| floatToByteTable |
| doubleToByteTable |
| stringToByteTable |
| wideStringToByteTable |
| Byte Table Conversions (Byte Table → Value) |
| byteTableToWord |
| byteTableToDword |
| byteTableToQword |
| byteTableToFloat |
| byteTableToDouble |
| byteTableToString |
| byteTableToWideString |