added floats, negative numbers

This commit is contained in:
afonya 2025-06-16 18:51:34 +02:00
parent 8aee85680a
commit cef2217c9e
Signed by: afonya
GPG key ID: EBB9C4CAFAAFB2DC
7 changed files with 79 additions and 82 deletions

View file

@ -13,7 +13,7 @@ pub struct DecompiledFunction {
pub struct DecompiledOperation {
pub opcode: u8,
pub arg1: u8,
pub arg2: i64,
pub arg2: f64,
pub arg3: u8,
pub pos: usize,
}
@ -100,22 +100,8 @@ fn bin_to_num(bin: String) -> usize {
return result;
}
fn bin_to_snum(bin: String) -> i64 {
let mut result: i64 = 0;
let mut is_negative = false;
for (i, c) in bin.chars().rev().enumerate() {
if c == '1' {
if i == bin.len() - 1 {
is_negative = true;
} else {
result += 1 << i;
}
}
}
if is_negative {
result = -result;
}
return result;
fn bin_to_snum(bin: String) -> f64 {
f64::from_bits(bin_to_num(bin) as u64)
}
fn load_func(data: Vec<u8>, offset: &mut usize) -> DecompiledFunction {