LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I display decimal data on the front panel as fractions such as 1/32, 1/16

Your bug probably has something to do with the fact that 2.8 is not exactly representable in binary floating point (e.g. DBL).

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 22 of 30
(1,262 Views)

Sorry, uploaded the wrong file.

CLA
0 Kudos
Message 23 of 30
(1,259 Views)

Same thing.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 24 of 30
(1,256 Views)

Getting the right file uploaded is harder than fixing the bug.

CLA
0 Kudos
Message 25 of 30
(1,255 Views)

Now handles values < 1 properly (including negatives)

CLA
Message 26 of 30
(1,235 Views)

Ok, final version suitable to use as a sub-vi.  I think I covered all the error handling.  Still could generate a custom error code if the fraction does not resolve but I don't really think that is necessary.

CLA
0 Kudos
Message 27 of 30
(1,210 Views)

1.33333 gives 1 3333/10000 instead of 1 1/3...

 

I still like the one I posted. Works with thirds, fifths, and sixths, or arbitrary list of possible denominators where the 2^n ones do not.

The XControl from paul_cardinale is awesome, but also doesn't handle thirds, returning 1 11/32 for 1.33333.

At some point I'm going to have to learn xcontrols, they look very useful. And I've run into some cases that also scream to be made into them...

0 Kudos
Message 28 of 30
(1,192 Views)

I cleaned up the code a bit.

Note: This method doesn't handle 1/3 & 2/3 well.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 29 of 30
(1,187 Views)

I've imcorporated it into the XControl

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 30 of 30
(1,171 Views)