LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a property to set the number of bits of a fixed point number?

I want to be able to programmatically change the properties of a fixed point numeric control that determine the total number of bits and integer bits.

 

I have not found a property that allows me to do that.

 

For example, in one iteration of the loop I want it to be 29 bits wide with 9 bits for the integer part, but in the next iteration I want it to be 15 bits wide with 8 bits for the integer part.

 

Can this be done?  Does anybody know how to?

 

Thanks,

 

AlejandroZ

0 Kudos
Message 1 of 13
(4,524 Views)

There is a property node called precision that will set the number of digits after the decimal point.  I don't know if there is a way to set the number of digits before the decimal point.  Right click on the numeric and select Create - Property Node - Display Format - Precision.

- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 13
(4,514 Views)

Just to be a bit more precise you have a double numeric control that is formatted to display a fixed decimal format and you want to know how to progamatically change the length and significant digits.

 

There is a FormatString property that you can feed a string to that gives you the formatting you want. You can play around with it by changing the format of the control (right click method) and then reading the FormatString property (display it with a string indicator) to see the string you should use to give you that format.

 

Then its just a matter of changing the property node to write and feeding the correct string to it.

0 Kudos
Message 3 of 13
(4,502 Views)

I do'nt think Alejandro is interested in the display format. Although I don't know the reasons behind, I believe he is referring to fixed point maths.

If this is the case, there is no way to change dynamically the representation of a number in memory, since this is decided at compilation time.

Chilly Charly    (aka CC)
Message 4 of 13
(4,486 Views)

If thats the case then he will have to scale, truncate, and rescale.

0 Kudos
Message 5 of 13
(4,481 Views)

 


Viper a écrit :

If thats the case then he will have to scale, truncate, and rescale.


Hmmm.... Such a transformation would change the value, but not the representation in memory, and the maths would give different results. As simple example, summing 200 + 200 do not give the same result wether you use U8, DBL or FXP(10,6). Still, I don't see what would be the purpose of changing dynamically the properties of a FXP.

Chilly Charly    (aka CC)
0 Kudos
Message 6 of 13
(4,471 Views)

Hi.

 

Indeed, I am not really interested in how the number is displayed, but rather on its bit-by-bit representation.

 

The reason I wanted to do this was to test some code in VHDL and make sure I get the same results, so I wanted to use LabVIEW as the known good converter to verify my code, in which the number of fractional bits is an input.

 

I am disappointed that it cannot be done dynamically...  I will have to change the VI for each bit length I want to test...

 

Thanks anyway.

 

AlejandroZ

0 Kudos
Message 7 of 13
(4,454 Views)

I'm curious.  How are you going to change the bit by bit representation.  I thought the compiler does this and that there is no control over this function.

- tbob

Inventor of the WORM Global
0 Kudos
Message 8 of 13
(4,443 Views)

 


tbob a écrit :

I'm curious.  How are you going to change the bit by bit representation.  I thought the compiler does this and that there is no control over this function.


Starting with LV 8.x, along with Integers, floats and complex, there has been a new category of numerics : the FPX (fixed point fractionals) . Drop one of these on the front panel, then go to "Properties >> Data type". There, you can define the overall number of bits and the number of bits used to represent the integer part of the number. For instance, you can decide to work with positive FP numbers made up with 4 bits only, and use 2 bits for the integer part, covering the range 0-3.75 in 0.25 steps.

Chilly Charly    (aka CC)
0 Kudos
Message 9 of 13
(4,422 Views)

@chilly charly wrote:

 


tbob a écrit :

I'm curious.  How are you going to change the bit by bit representation.  I thought the compiler does this and that there is no control over this function.


Starting with LV 8.x, along with Integers, floats and complex, there has been a new category of numerics : the FPX (fixed point fractionals) .


Actually LabVIEW 8.5 was the first to have the FXP data type. Smiley Wink

0 Kudos
Message 10 of 13
(4,411 Views)