<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Simple multiplication gives incorrect results in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/simple-multiplication-gives-incorrect-results/m-p/5080244#M25002</link>
    <description>&lt;!--!*#--&gt;I have a dcl script that multiplies the number of freeblocks of a device by the block size (512) to give me approximate Megabytes, but it gives me an incorrect value.&lt;BR /&gt;&lt;BR /&gt;Actual example:&lt;BR /&gt;FS = f$getdvi("DISK1","FREEBLOCKS")&lt;BR /&gt;MB = FS*512&lt;BR /&gt;display FS --&amp;gt; 4995264&lt;BR /&gt;display MB --&amp;gt; -1737392128&lt;BR /&gt;expecting MB to be 2557575168&lt;BR /&gt;</description>
    <pubDate>Mon, 19 Nov 2007 13:44:25 GMT</pubDate>
    <dc:creator>GaryM</dc:creator>
    <dc:date>2007-11-19T13:44:25Z</dc:date>
    <item>
      <title>Simple multiplication gives incorrect results</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/simple-multiplication-gives-incorrect-results/m-p/5080244#M25002</link>
      <description>&lt;!--!*#--&gt;I have a dcl script that multiplies the number of freeblocks of a device by the block size (512) to give me approximate Megabytes, but it gives me an incorrect value.&lt;BR /&gt;&lt;BR /&gt;Actual example:&lt;BR /&gt;FS = f$getdvi("DISK1","FREEBLOCKS")&lt;BR /&gt;MB = FS*512&lt;BR /&gt;display FS --&amp;gt; 4995264&lt;BR /&gt;display MB --&amp;gt; -1737392128&lt;BR /&gt;expecting MB to be 2557575168&lt;BR /&gt;</description>
      <pubDate>Mon, 19 Nov 2007 13:44:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/simple-multiplication-gives-incorrect-results/m-p/5080244#M25002</guid>
      <dc:creator>GaryM</dc:creator>
      <dc:date>2007-11-19T13:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: Simple multiplication gives incorrect results</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/simple-multiplication-gives-incorrect-results/m-p/5080245#M25003</link>
      <description>DCL can only handle 31 bit signed arithmetic. If you overflow 2^31 you will get a negative number with no error message because bit #31 is set and that is interpreted as the sign bit.  If you overflow 2^32 the answer will wrap back over 0.  Note with the numbers you posted:&lt;BR /&gt;&lt;BR /&gt; 1737392128&lt;BR /&gt;+2557575168&lt;BR /&gt;-----------&lt;BR /&gt; 4294967296 = hex 100000000 = 2^32&lt;BR /&gt;</description>
      <pubDate>Mon, 19 Nov 2007 14:01:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/simple-multiplication-gives-incorrect-results/m-p/5080245#M25003</guid>
      <dc:creator>Jess Goodman</dc:creator>
      <dc:date>2007-11-19T14:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: Simple multiplication gives incorrect results</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/simple-multiplication-gives-incorrect-results/m-p/5080246#M25004</link>
      <description>I should have added that if you just want the number of free Megabytes on the disk then do a division intead of multiplying.&lt;BR /&gt;(When you multiplied by 512 you were calclating the number of free bytes, not megabytes.)&lt;BR /&gt;&lt;BR /&gt;FS = f$getdvi("DISK1","FREEBLOCKS")&lt;BR /&gt;MB = FS/2048&lt;BR /&gt;&lt;BR /&gt;1 Block = 512 Bytes = 0.5 KiloBytes&lt;BR /&gt;1 MegaByte = 1024 KiloBytes&lt;BR /&gt;&lt;BR /&gt;And welcome to the IT resource center forums.&lt;BR /&gt;</description>
      <pubDate>Mon, 19 Nov 2007 14:12:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/simple-multiplication-gives-incorrect-results/m-p/5080246#M25004</guid>
      <dc:creator>Jess Goodman</dc:creator>
      <dc:date>2007-11-19T14:12:50Z</dc:date>
    </item>
    <item>
      <title>Re: Simple multiplication gives incorrect results</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/simple-multiplication-gives-incorrect-results/m-p/5080247#M25005</link>
      <description>&amp;gt; DCL can only handle 31 bit signed arithmetic.&lt;BR /&gt;&lt;BR /&gt;That's normally called 32-bit signed&lt;BR /&gt;arithmetic.  One of the 32 bits is a sign&lt;BR /&gt;bit.&lt;BR /&gt;&lt;BR /&gt;I don't recall a comp.os.vms question this&lt;BR /&gt;year from anyone wondering why some simple&lt;BR /&gt;floating-point calculation wasn't exact.  Is&lt;BR /&gt;this as close as we get for 2007?</description>
      <pubDate>Mon, 19 Nov 2007 14:27:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/simple-multiplication-gives-incorrect-results/m-p/5080247#M25005</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2007-11-19T14:27:43Z</dc:date>
    </item>
    <item>
      <title>Re: Simple multiplication gives incorrect results</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/simple-multiplication-gives-incorrect-results/m-p/5080248#M25006</link>
      <description>Thanks for the explanations.  That did the trick.</description>
      <pubDate>Mon, 19 Nov 2007 14:33:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/simple-multiplication-gives-incorrect-results/m-p/5080248#M25006</guid>
      <dc:creator>GaryM</dc:creator>
      <dc:date>2007-11-19T14:33:28Z</dc:date>
    </item>
  </channel>
</rss>

