<p>Kevin Harwell <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/16079">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Kevin Harwell: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">func_math: Return integer instead of float if possible<br><br>The MIN, MAX, and ABS functions all support float<br>arguments, but currently return floats even if the<br>arguments are all integers and the response is<br>a whole number, in which case the user is likely<br>expecting an integer. This casts the float to an integer<br>before printing into the response buffer if possible.<br><br>ASTERISK-29495<br><br>Change-Id: I902d29eacf3ecd0f8a6a5e433c97f0421d205488<br>---<br>M funcs/func_math.c<br>1 file changed, 15 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/funcs/func_math.c b/funcs/func_math.c</span><br><span>index b8a6eb6..76d1a74 100644</span><br><span>--- a/funcs/func_math.c</span><br><span>+++ b/funcs/func_math.c</span><br><span>@@ -525,7 +525,11 @@</span><br><span>    }</span><br><span> </span><br><span>        ast_debug(1, "%f is the minimum of [%f,%f]\n", response_num, num1, num2);</span><br><span style="color: hsl(0, 100%, 40%);">-     snprintf(buffer, buflen, "%f", response_num);</span><br><span style="color: hsl(120, 100%, 40%);">+       if ((int) response_num == response_num) {</span><br><span style="color: hsl(120, 100%, 40%);">+             snprintf(buffer, buflen, "%d", (int) response_num);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+              snprintf(buffer, buflen, "%f", response_num);</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span> </span><br><span>        return 0;</span><br><span> }</span><br><span>@@ -567,7 +571,11 @@</span><br><span>        }</span><br><span> </span><br><span>        ast_debug(1, "%f is the maximum of [%f,%f]\n", response_num, num1, num2);</span><br><span style="color: hsl(0, 100%, 40%);">-     snprintf(buffer, buflen, "%f", response_num);</span><br><span style="color: hsl(120, 100%, 40%);">+       if ((int) response_num == response_num) {</span><br><span style="color: hsl(120, 100%, 40%);">+             snprintf(buffer, buflen, "%d", (int) response_num);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+              snprintf(buffer, buflen, "%f", response_num);</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span> </span><br><span>        return 0;</span><br><span> }</span><br><span>@@ -589,7 +597,11 @@</span><br><span> </span><br><span>    response_num = fabs(num1);</span><br><span>   ast_debug(1, "%f is the absolute value of %f\n", response_num, num1);</span><br><span style="color: hsl(0, 100%, 40%);">- snprintf(buffer, buflen, "%f", response_num);</span><br><span style="color: hsl(120, 100%, 40%);">+       if ((int) response_num == response_num) {</span><br><span style="color: hsl(120, 100%, 40%);">+             snprintf(buffer, buflen, "%d", (int) response_num);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+              snprintf(buffer, buflen, "%f", response_num);</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span> </span><br><span>        return 0;</span><br><span> }</span><br><span></span><br></pre><div style="white-space:pre-wrap"></div><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/16079">change 16079</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/16079"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I902d29eacf3ecd0f8a6a5e433c97f0421d205488 </div>
<div style="display:none"> Gerrit-Change-Number: 16079 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: N A <mail@interlinked.x10host.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>