LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert a floating point number into fixpoint 18bit/4Int and represent it in HEX true form (NOT FFAE*2^-14 for example)

Solved!
Go to solution

As an example for what I would like to do: A floating point number can be coded as true form HEX like that (fxp 18/4):

-1,6554565429687500e+00 -> 1001 / 1010 / 0111 / 1100 / 1100 thus 9A7CC (9 is the signed integer part - MSB 1 beacause negativ). Is there a good way to make this translation?

0 Kudos
Message 1 of 8
(4,028 Views)
Sorry - the previous posting was wrong - its all about twos complement. Thus representing -1.xx like 1111 (integer part). Next time I will be more carefull Smiley Tongue
0 Kudos
Message 2 of 8
(4,015 Views)

ven_to wrote:
Next time I will be more carefull Smiley Tongue

Does this mean the problem is solved or do you still need help?

0 Kudos
Message 3 of 8
(4,004 Views)

The mantissa part of a float/double should hold the bit pattern you're interested in. Copy it to an integer and shift to match your fixed pattern. I think that's all.

 

/Y

 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 8
(3,990 Views)

Oh no.... unfortunately I still have the problem. I just formulated it not correctly in my first (ever) posting.

I have filter coefficients represented in floating point - the transformation in FPGA usable presentation (in my case 18bit/4Int) looks like represented below. Since this is a standard representation I suppose there is an easy way to represent this in LabView, but I don't find it.

 

-1,6554565429687500e+00 -> bin 1 110 01011000001110 -> 0x3960E

0 Kudos
Message 5 of 8
(3,980 Views)

I dont think there's an easy way to do it, but it shouldn't be too hard either.

 

My previous answer still holds, but might need some explanation.

 

A float is stored as mantissa+exponent (much like the way you wrote the number). Assuming exponent is 0 (typically a number slightly between 0,5 - 1) the mantissa part IS your number. As such, bitmask that number to an integer and you've got it as fixed point (32/0). Shift the number as needed to move the "binal" point.

 

0,34512*2^0 (mantissa+exp)

0,34512 (mantissa)

34512 (fixed point version)

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 8
(3,975 Views)
Solution
Accepted by topic author ven_to

Just cast the FXP to a U32, shift right by 14 bits, and display....

 

Message Edited by altenbach on 12-04-2009 08:14 AM
0 Kudos
Message 7 of 8
(3,961 Views)

Thank you Altenbach, Knight of NI 🙂 !!!

Thank you, too Yamaeda!

 

Everything work fine now.

0 Kudos
Message 8 of 8
(3,941 Views)