[DiscordArchive] They are dividing by 0x7FFF there?
[DiscordArchive] They are dividing by 0x7FFF there?
Archived author: Skarn • Posted: 2018-06-06T08:28:19.453000+00:00
Original source
You said it fails to read most values
Archived author: schlumpf • Posted: 2018-06-06T08:30:28.704000+00:00
Original source
It tried to handle fixed16 and fixed_point the same, which is wrong.
The part it mostly failed with was writing iirc, with off by one rounding errors.
Archived author: Skarn • Posted: 2018-06-06T08:30:43.931000+00:00
Original source
```py
class fixed_point:
"""A fixed point real number, opposed to a floating point."""
def __init__(self, type_, dec_bits, int_bits):
self.type = type_
self.dec_bits = dec_bits
self.int_bits = int_bits
self.value = 0
def read(self, f):
fixed_point_val = self.type.read(f)
decimal_part = fixed_point_val & ((1 << self.dec_bits) - 1)
integral_part = (fixed_point_val >> self.dec_bits) & (1 << self.int_bits) - 1
sign = -1.0 if (fixed_point_val & (1 << (self.dec_bits + self.int_bits)) != 0) else 1.0
self.value = sign * (integral_part + decimal_part / (((1 << self.dec_bits) - 1) + 1.0))
return self
def write(self, f):
sign = 1 if self.value < 0 else 0
integral_part = int(self.value) & ((1 << self.int_bits) - 1)
decimal_part = int((self.value - int(self.value)) * (1 << self.dec_bits))
fixed_point_val = (sign << (self.int_bits + self.dec_bits)) | (integral_part << self.int_bits) | decimal_part
self.type.write(f, fixed_point_val)
return self
```
Archived author: Skarn • Posted: 2018-06-06T08:30:48.697000+00:00
Original source
That's the code I am talking about btw
Archived author: Skarn • Posted: 2018-06-06T08:31:09.150000+00:00
Original source
Can you propose any solution to rounding though?
Archived author: schlumpf • Posted: 2018-06-06T08:33:09.905000+00:00
Original source
The code tries to implement fp as if it was fixed16 for read, so that will be wrong for any non fixed16. I can’t comment on my write function.
Archived author: schlumpf • Posted: 2018-06-06T08:33:23.044000+00:00
Original source
TLDR: ignore me and just do what others said above
Archived author: Skarn • Posted: 2018-06-06T08:37:28.058000+00:00
Original source
<@250706991515828224> is your viewer capable of showing individual models like WMV?
Archived author: Deamon • Posted: 2018-06-06T08:37:50.196000+00:00
Original source
<@197724887387734016> yes
Archived author: Deamon • Posted: 2018-06-06T08:38:07.080000+00:00
Original source
the UI though is not there