11-18-2007 03:09 PM
11-18-2007 03:16 PM - edited 11-18-2007 03:18 PM
08-21-2025 03:29 AM - edited 08-21-2025 03:31 AM
I undestand this is an ancient topic, but for reference, this should be a free implementation
If we're talking pure bitwise split the snippet works.
Regarding negative numbers: in the dual complement, negative numbers can be read as "whole part rounded towards -infinity" + (1 - decimal part):
Bitwise split works as intended. Additionally, looking at the split as values: if you add the Whole FXP and Decimal FXP value is equal to FXP value.
08-21-2025 03:42 AM - edited 08-21-2025 03:49 AM
Hi blaz,
@blaz-kelbl wrote:
this should be a free implementation
What's "free" in this implementation?
Why go from FXP to bitarray to integer to FXP?
@blaz-kelbl wrote:
Bitwise split works as intended.
Sure.
But when working with integers you don't need any bitarrays, use plain boolean operations (AND, OR, shift) instead!
To put it in other words: you only need blue wires!
Edit: added the orange way of getting quotient and remainder…
08-21-2025 03:47 AM
I meant free as in uses no resources, but your implementation is actually more elegant and should also use no resources (maybe I missed a post).
The back conversion was just to illustrate.
08-21-2025 03:53 AM
Hi blaz,
@blaz-kelbl wrote:
I meant free as in uses no resources,
This only is valid on LV-FPGA.
In other environments (Win, RT) a bitarray uses way more memory than your underlying FXP datatype (or INT or FLOAT)!
08-21-2025 04:03 AM
Correct, I mistakenly assumed the question was in the context of FPGA
(I think I just replied to the incorrect forum post) https://lavag.org/topic/23873-how-to-separate-decimals-and-integers-on-the-fpga-side/
Anyway, your solution is best.