<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264554</link>
    <title>MATLAB Central Newsreader - reinterpret double as fix point</title>
    <description>Feed for thread: reinterpret double as fix point</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Fri, 30 Oct 2009 11:38:07 -0400</pubDate>
      <title>reinterpret double as fix point</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264554#690933</link>
      <author>Stefan Jakobs</author>
      <description>Hello,&lt;br&gt;
&lt;br&gt;
I'm converting a double value to a fix point value and then pass that value to a mex file. The return type of the mex file is double, but the actual value is of type fix point.&lt;br&gt;
So, how can I make matlab to recognise the double value as a fix point value?&lt;br&gt;
&lt;br&gt;
example (fix_point is the mex file):&lt;br&gt;
&lt;br&gt;
a = fix_point(fi(-1.5, true, 4, 2))&lt;br&gt;
class(a)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ans = double&lt;br&gt;
a&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ans =  2.1220e-314&lt;br&gt;
&lt;br&gt;
But that is the wrong value, because 'a' should be interpreted as type fi.&lt;br&gt;
&lt;br&gt;
Thanks for your help.&lt;br&gt;
Greetings&lt;br&gt;
Stefan</description>
    </item>
    <item>
      <pubDate>Fri, 30 Oct 2009 12:43:26 -0400</pubDate>
      <title>Re: reinterpret double as fix point</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264554#690940</link>
      <author>Tom Bryan</author>
      <description>Hello Stefan,&lt;br&gt;
&lt;br&gt;
There is no public interface for the fi object in hand-written mex files.&lt;br&gt;
&lt;br&gt;
However, you can compile a MATLAB function into a mex function with fi &lt;br&gt;
inputs and outputs using emlmex.&lt;br&gt;
&lt;br&gt;
If you want to use handwritten mex files, then use builtin integer &lt;br&gt;
inputs and outputs, and cast to and from fi objects outside of the mex &lt;br&gt;
function.&lt;br&gt;
&lt;br&gt;
Let me know if you need more details.&lt;br&gt;
&lt;br&gt;
Best wishes,&lt;br&gt;
Tom Bryan&lt;br&gt;
tom.bryan@mathworks.com&lt;br&gt;
&lt;br&gt;
Stefan Jakobs wrote:&lt;br&gt;
&amp;gt; Hello,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I'm converting a double value to a fix point value and then pass that value to a mex file. The return type of the mex file is double, but the actual value is of type fix point.&lt;br&gt;
&amp;gt; So, how can I make matlab to recognise the double value as a fix point value?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; example (fix_point is the mex file):&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; a = fix_point(fi(-1.5, true, 4, 2))&lt;br&gt;
&amp;gt; class(a)&lt;br&gt;
&amp;gt;       ans = double&lt;br&gt;
&amp;gt; a&lt;br&gt;
&amp;gt;       ans =  2.1220e-314&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; But that is the wrong value, because 'a' should be interpreted as type fi.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks for your help.&lt;br&gt;
&amp;gt; Greetings&lt;br&gt;
&amp;gt; Stefan</description>
    </item>
  </channel>
</rss>

