added floats, negative numbers
This commit is contained in:
parent
8aee85680a
commit
cef2217c9e
7 changed files with 79 additions and 82 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue