<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Confusion with Lreal to dword</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/4b094c86bc/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/4b094c86bc/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/CODESYS-V2/thread/4b094c86bc/</id><updated>2020-02-27T20:06:37.502000Z</updated><subtitle>Recent posts to Confusion with Lreal to dword</subtitle><entry><title>Confusion with Lreal to dword</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/4b094c86bc/?limit=25#63fa" rel="alternate"/><published>2020-02-27T20:06:37.502000Z</published><updated>2020-02-27T20:06:37.502000Z</updated><author><name>sarathbabu</name><uri>https://forge.codesys.com/u/sarathbabu/</uri></author><id>https://forge.codesys.comc270fe92bb52e41387f52537946682f3f42169bf</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Yes declaring it as integer is the problem.&lt;br/&gt;
Actually i do not need decimal points thats y i tried this conversion&lt;/p&gt;
&lt;p&gt;Thank u&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Confusion with Lreal to dword</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/4b094c86bc/?limit=25#e52e" rel="alternate"/><published>2020-02-27T20:06:33.708000Z</published><updated>2020-02-27T20:06:33.708000Z</updated><author><name>shooter</name><uri>https://forge.codesys.com/u/shooter/</uri></author><id>https://forge.codesys.com65e03f2dc5306a2662b8359f86170c9be5abe081</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;rounding up a value is simpler with round from the oscat lib.&lt;br/&gt;
it is more predictable, and the way it should be done.&lt;br/&gt;
you are doing a trick and suppose the conversion is good, but a real is totally different from a word.&lt;br/&gt;
the biggest problem is you do not know how 3 is declared as a byte or as a word or anything.&lt;br/&gt;
so make all variables declared this way the result is predicatable.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Confusion with Lreal to dword</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/4b094c86bc/?limit=25#ea55" rel="alternate"/><published>2020-02-27T20:06:32.266000Z</published><updated>2020-02-27T20:06:32.266000Z</updated><author><name>chab</name><uri>https://forge.codesys.com/u/chab/</uri></author><id>https://forge.codesys.comd18ec0eb2fdb4944edfe683ae0539022f9378522</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Maybe (3/5) is handled as an integer first. Which results in 0.&lt;/p&gt;
&lt;p&gt;Try it with a variable like:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;var_in&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;lreal&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;var_out&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;dword&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;var_in&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;var_out&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;Lreal_to_dword&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;in&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="n"&gt;var_in&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</summary></entry><entry><title>Confusion with Lreal to dword</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/4b094c86bc/?limit=25#2c31" rel="alternate"/><published>2020-02-27T20:06:30.958000Z</published><updated>2020-02-27T20:06:30.958000Z</updated><author><name>sarathbabu</name><uri>https://forge.codesys.com/u/sarathbabu/</uri></author><id>https://forge.codesys.com8c8ec1d94a5419582f8885915716e76893d23e12</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;When ever am using this in program, it is supposed to round up the value and give answer&lt;/p&gt;
&lt;p&gt;eg:Lreal_to_dword(in:=(3/5))&lt;/p&gt;
&lt;p&gt;answer to this is supposed to be 1 but some how in my program it is zero,Can any help me on this&lt;/p&gt;
&lt;p&gt;Thanks&lt;br/&gt;
Sarath&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>