Difference between revisions of "Lua:byteTableToDouble"

From Cheat Engine
Jump to navigation Jump to search
(Created page with ''''function''' byteTableToDouble(''Table'') Converts a byte table to a QWORD (8 bytes), interpreting them as a double precision floating point value. === Function Parameters =…')
 
m
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''function''' byteTableToDouble(''Table'')
+
[[Category:Lua]]
 +
'''function''' byteTableToDouble(''Table'') ''':''' Number
  
Converts a byte table to a QWORD (8 bytes), interpreting them as a double precision floating point value.
+
Converts a table of bytes to a double precision (64-bit) floating point number.
  
 
+
===Function Parameters===
=== Function Parameters ===
+
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
{|width="85%" cellpadding="10%" cellpadding="5%" cellspacing="0" border="0"
 
 
!align="left"|Parameter
 
!align="left"|Parameter
 
!align="left"|Type
 
!align="left"|Type
Line 11: Line 11:
 
|-
 
|-
 
|Table
 
|Table
|table
+
|Table
|The table of bytes to convert
+
|A table containing the bytes to convert (least significant byte first).
 
|}
 
|}
  
 +
===Returns===
 +
Number — The resulting double precision floating point value.
  
== Examples ==
+
===Explanation===
Code:
+
The function takes a table of bytes (e.g., <code>{0x1F, 0x85, 0xEB, 0x51, 0xB8, 0x1E, 0x09, 0x40}</code>) and interprets them as a 64-bit double in little-endian order.
  local bt = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0x40 }
 
  local value = byteTableToDouble(bt)
 
  print(string.format('0x%0X', value))
 
  print(value)
 
  
Output:
+
For example, <code>byteTableToDouble({0x1F, 0x85, 0xEB, 0x51, 0xB8, 0x1E, 0x09, 0x40})</code> returns <code>3.14</code>.
  0x64
 
  100.0
 
  
 +
===Examples===
 +
<pre>
 +
local doubleValue = byteTableToDouble({0x1F, 0x85, 0xEB, 0x51, 0xB8, 0x1E, 0x09, 0x40})
 +
print(doubleValue) -- Output: 3.14
 +
</pre>
  
== See also ==
+
{{LuaSeeAlso}}
* [[Lua]]
 
* [[Help_File:Script engine|Script engine]]
 
  
 
=== Related Functions ===
 
=== Related Functions ===
* [[readBytes]]
+
{{ReadWriteMemory}}
* [[readInteger]]
 
* [[readQword]]
 
* [[readPointer]]
 
* [[readFloat]]
 
* [[readDouble]]
 
* [[readString]]
 
* [[writeBytes]]
 
* [[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]]
 
* [[byteTableToString]]
 
* [[byteTableToWideString]]
 

Revision as of 17:41, 11 July 2025

function byteTableToDouble(Table) : Number

Converts a table of bytes to a double precision (64-bit) floating point number.

Function Parameters

Parameter Type Description
Table Table A table containing the bytes to convert (least significant byte first).

Returns

Number — The resulting double precision floating point value.

Explanation

The function takes a table of bytes (e.g., {0x1F, 0x85, 0xEB, 0x51, 0xB8, 0x1E, 0x09, 0x40}) and interprets them as a 64-bit double in little-endian order.

For example, byteTableToDouble({0x1F, 0x85, 0xEB, 0x51, 0xB8, 0x1E, 0x09, 0x40}) returns 3.14.

Examples

local doubleValue = byteTableToDouble({0x1F, 0x85, 0xEB, 0x51, 0xB8, 0x1E, 0x09, 0x40})
print(doubleValue) -- Output: 3.14

See also

Lua
Script Engine

Related Functions

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