02-24-2010 10:55 AM
Hello,
The TIFF tag header protocol requires a data type I am not really conversant with, the Rational Data type: http://en.wikipedia.org/wiki/Rational_data_type
I need to convert double precision numbers to this data type, e.g. 24.5 needs to be a ratio of two integers: {49,2}. Is there an existing LabVIEW algorithm to perform this operation? All my NI searches keep resulting in Rational ClearCase or Rational Array interpolation. I seem to have found a lot of the theory behind this: http://stackoverflow.com/questions/95727/how-to-convert-floats-to-human-readable-fractions
But, is this implemented in labVIEW already, or should I implement the above-referenced c-code?
Thanks,
Mello
Solved! Go to Solution.
02-24-2010 11:01 AM - edited 02-24-2010 11:01 AM
That implementation is not in LabVIEW. Perhaps you may wish to post a suggestion to add it to a future release of LabVIEW.
If you have C code that will do it then you can call it using Call Library Function Node . You'll either need a DLL or you'll need to create one. Or, you can just convert the code to LabVIEW.
02-24-2010 12:00 PM
Thank you smercurio, I think I am going to go with the workaround/kluge method of multiplying by a power of ten and truncating:
23.5 => {23500, 1000}
I will add a suggestion that a more elegant solution be made part of the NI math or numeric palettes.
-Mello
02-24-2010 12:06 PM - edited 02-24-2010 12:09 PM
Hi,
Maybe you can make use of Altenbach's fraction code in the last post in this link can help you.
cheers
David
02-24-2010 01:31 PM - edited 02-24-2010 01:33 PM
This should be possible if you have MathScript available.
see attached ( LV 8.6.1)
02-24-2010 01:51 PM
Thanks Phillip!
A Matlab user such as myself should have thought of that method 🙂
02-24-2010 01:54 PM
02-24-2010 03:33 PM
Phillip Brooks wrote:This should be possible if you have MathScript available.
Neat. Didn't know that function existed in MathScript.
Note that for LV 2009 one requires a separate license for MathScript. There was a big long debate about this when 2009 was released. Every bitched and moaned. It was fun reading. Not so much fun for those who had to shell out more cash for it though.
03-04-2010 07:26 AM - edited 03-04-2010 07:29 AM
I was curious if there were other ways to do this and found that Scilab combined with the LabVIEW Gateway works quite well. The 'rat' function is available in Scilab; Scilab and the LabVIEW gateway were both easy to install...
http://www.scilab.org/products/other/labview_gateway
12-08-2015 10:02 AM - edited 12-08-2015 10:04 AM
Since LabVIEW has a vi to return the greatest common multiple, it's not hard to make a vi to get to fractions. This snippet solves a similiar problem of converting the floating point number to string whole number plus a fraction.