86 lines
5.3 KiB
HTML
86 lines
5.3 KiB
HTML
|
<?xml version="1.0" encoding="UTF-8"?>
|
||
|
<!DOCTYPE html
|
||
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
<html lang="en-us" xml:lang="en-us">
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
|
<meta name="security" content="public" />
|
||
|
<meta name="Robots" content="index,follow" />
|
||
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
||
|
<meta name="DC.Type" content="concept" />
|
||
|
<meta name="DC.Title" content="Handle the divide-by-zero errors" />
|
||
|
<meta name="abstract" content="Dividing by zero is considered an error by the Open Query File (OPNQRYF) command. This topic discusses how to handle the divide-by-zero error in case that you want a zero answer." />
|
||
|
<meta name="description" content="Dividing by zero is considered an error by the Open Query File (OPNQRYF) command. This topic discusses how to handle the divide-by-zero error in case that you want a zero answer." />
|
||
|
<meta name="DC.subject" content="divide by zero, handling" />
|
||
|
<meta name="keywords" content="divide by zero, handling" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="rbafodynrs.htm" />
|
||
|
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
|
||
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
|
||
|
<meta name="DC.Format" content="XHTML" />
|
||
|
<meta name="DC.Identifier" content="rbafodbz" />
|
||
|
<meta name="DC.Language" content="en-us" />
|
||
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
||
|
<!-- US Government Users Restricted Rights -->
|
||
|
<!-- Use, duplication or disclosure restricted by -->
|
||
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
||
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
||
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
||
|
<title>Handle the divide-by-zero errors</title>
|
||
|
</head>
|
||
|
<body id="rbafodbz"><a name="rbafodbz"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">Handle the divide-by-zero errors</h1>
|
||
|
<div><p>Dividing by zero is considered an error by the Open Query File
|
||
|
(OPNQRYF) command. This topic discusses how to handle the divide-by-zero error
|
||
|
in case that you want a zero answer. </p>
|
||
|
<p>Record selection is normally done before field mapping errors occur. Therefore,
|
||
|
a record can be omitted that would have caused a divide-by-zero error and
|
||
|
in this case, processing by the OPNQRYF command would continue. If you want
|
||
|
a zero answer, here is a solution that is practical for typical commercial
|
||
|
data.</p>
|
||
|
<p>Assume that you want to divide A by B giving C (stated as A / B = C). Assume
|
||
|
the following definitions where B can be zero.</p>
|
||
|
|
||
|
<table cellpadding="4" cellspacing="0" border="1" class="tableborder"><tr><td>
|
||
|
<table cellpadding="4" cellspacing="0" summary="" width="100%" border="0"><thead align="left"><tr><th align="center" valign="bottom" width="33.401221995926676%" id="d0e28">Field</th>
|
||
|
<th align="center" valign="bottom" width="37.4745417515275%" id="d0e30">Digits</th>
|
||
|
<th align="center" valign="bottom" width="29.124236252545828%" id="d0e32">Dec</th>
|
||
|
</tr>
|
||
|
</thead>
|
||
|
<tbody><tr><td align="center" valign="top" width="33.401221995926676%" headers="d0e28 ">A</td>
|
||
|
<td align="center" valign="top" width="37.4745417515275%" headers="d0e30 ">6</td>
|
||
|
<td align="center" valign="top" width="29.124236252545828%" headers="d0e32 ">2</td>
|
||
|
</tr>
|
||
|
<tr><td align="center" valign="top" width="33.401221995926676%" headers="d0e28 ">B</td>
|
||
|
<td align="center" valign="top" width="37.4745417515275%" headers="d0e30 ">3</td>
|
||
|
<td align="center" valign="top" width="29.124236252545828%" headers="d0e32 ">0</td>
|
||
|
</tr>
|
||
|
<tr><td align="center" valign="top" width="33.401221995926676%" headers="d0e28 ">C</td>
|
||
|
<td align="center" valign="top" width="37.4745417515275%" headers="d0e30 ">6</td>
|
||
|
<td align="center" valign="top" width="29.124236252545828%" headers="d0e32 ">2</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</td></tr></table>
|
||
|
<div class="p">The following algorithm can be used: <pre>(A * B) / %MAX((B * B) .nnnn1)</pre>
|
||
|
</div>
|
||
|
<p>The %MAX function returns the maximum value of either B * B or a small
|
||
|
value. The small value must have enough leading zeros so that it is less than
|
||
|
any value calculated by B * B unless B is zero. In this example, B has zero
|
||
|
decimal positions so .1 can be used. The number of leading zeros should be
|
||
|
2 times the number of decimals in B. For example, if B had 2 decimal positions,
|
||
|
then .00001 should be used.</p>
|
||
|
<div class="p">Specify the following MAPFLD definition: <pre>MAPFLD((C '(A * B) / %MAX((B * B) .1)'))</pre>
|
||
|
</div>
|
||
|
<p>The intent of the first multiplication is to produce a zero dividend if
|
||
|
B is zero. This ensures a zero result when the division occurs. Dividing by
|
||
|
zero does not occur if B is zero because the .1 value will be the value used
|
||
|
as the divisor.</p>
|
||
|
</div>
|
||
|
<div>
|
||
|
<div class="familylinks">
|
||
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafodynrs.htm" title="Dynamic record selection allows you to request a subset of the records in a file without using data description specifications (DDS).">Select records without using DDS</a></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|