<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>299.65 is automatically converting to 299.64.</title><link>https://community.appian.com/discussions/f/user-interface/29589/299-65-is-automatically-converting-to-299-64</link><description>Hi, 
 Whenever I&amp;#39;m trying to enter 271.64 or 2**.65 where (** can be any number) it&amp;#39;s getting converted to 2**.64 
 I&amp;#39;m using below expression for this: 
 a!floatingPointField( label: &amp;quot;Test Decimal Value&amp;quot;, value: todecimal(fixed(trunc(ri!value, 2))),</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: 299.65 is automatically converting to 299.64.</title><link>https://community.appian.com/thread/117599?ContentTypeID=1</link><pubDate>Fri, 11 Aug 2023 13:18:40 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:662b9488-0e2c-432e-8f82-7408e4ff2d94</guid><dc:creator>Mathieu Drouin</dc:creator><description>&lt;p&gt;I agree with Chris and James&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use fixed only - trunc is not necessary.&lt;/li&gt;
&lt;li&gt;Put the fixed in the saveInto rather than the value&lt;/li&gt;
&lt;li&gt;You can optionally combine fixed with round (see KB article below)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I don&amp;#39;t think the todecimal is really necessary.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!floatingPointField(
  label: &amp;quot;Test Decimal Value&amp;quot;,
  value: ri!value,
  saveInto: {
    a!save(
      ri!value,
      if(
        a!isNotNullOrEmpty(save!value),
        fixed(save!value, 2),
        null
      )
    )
  }
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/13/pastedimage1691764408240v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;More info found in this KB article:&amp;nbsp;&lt;a href="/support/w/kb/707/kb-1426-unexpected-results-on-decimal-calculations-and-rounding"&gt;https://community.appian.com/support/w/kb/707/kb-1426-unexpected-results-on-decimal-calculations-and-rounding&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 299.65 is automatically converting to 299.64.</title><link>https://community.appian.com/thread/117597?ContentTypeID=1</link><pubDate>Fri, 11 Aug 2023 12:12:06 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:000c4dd4-cb8c-4e4b-b9ee-c45286a73ecf</guid><dc:creator>jamesm4933</dc:creator><description>&lt;p&gt;I can imagine you are frustrated, and under some stress.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;However, I think you should take a breath and calm down, then re-read the advice you have received, because you have not actually followed it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 299.65 is automatically converting to 299.64.</title><link>https://community.appian.com/thread/117491?ContentTypeID=1</link><pubDate>Wed, 09 Aug 2023 15:53:11 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ddc7f080-abac-492e-b280-2b2b37f8f287</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;If we don&amp;#39;t want rounding, the combination of only fixed() and trunc() should do this for you:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;a!floatingPointField(
  label: &amp;quot;Test&amp;quot;,
  value: ri!value,
  saveInto: a!save(
    ri!value,
    if(
      rule!APN_isEmpty(save!value),
      0.00,
      fixed(trunc(save!value,2),2)
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 299.65 is automatically converting to 299.64.</title><link>https://community.appian.com/thread/117433?ContentTypeID=1</link><pubDate>Wed, 09 Aug 2023 07:42:26 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ea7d7575-af17-4444-ae17-a924d71a9657</guid><dc:creator>shobhits6437</dc:creator><description>&lt;p&gt;Already tried, but this rounds off to next integer value, which is not the expectation here. Like:&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/13/pastedimage1691566837313v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 299.65 is automatically converting to 299.64.</title><link>https://community.appian.com/thread/117432?ContentTypeID=1</link><pubDate>Wed, 09 Aug 2023 07:42:09 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:5ace49b1-d8e9-499b-835d-890d66037551</guid><dc:creator>shobhits6437</dc:creator><description>&lt;p&gt;Already tried, but this rounds off to next integer value, which is not the expectation here. Like:&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/13/pastedimage1691566821353v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 299.65 is automatically converting to 299.64.</title><link>https://community.appian.com/thread/117431?ContentTypeID=1</link><pubDate>Wed, 09 Aug 2023 07:41:40 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e1d57281-23dd-4795-ba30-298dae18377f</guid><dc:creator>shobhits6437</dc:creator><description>&lt;p&gt;Already tried, but this rounds off to next integer value, which is not the expectation here. Like:&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/13/pastedimage1691566785512v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 299.65 is automatically converting to 299.64.</title><link>https://community.appian.com/thread/117430?ContentTypeID=1</link><pubDate>Wed, 09 Aug 2023 07:39:50 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a28a48d8-04ae-45f5-99b8-4acb76e29242</guid><dc:creator>shobhits6437</dc:creator><description>&lt;p&gt;Already tried, but this rounds off to next integer value, which is not the expectation here. Like:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/13/pastedimage1691566683221v1.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 299.65 is automatically converting to 299.64.</title><link>https://community.appian.com/thread/117428?ContentTypeID=1</link><pubDate>Wed, 09 Aug 2023 07:38:06 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d69c50e9-22fd-4921-b918-59c49f3e1e67</guid><dc:creator>shobhits6437</dc:creator><description>&lt;p&gt;This is not keeping up to two decimal places.&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/13/pastedimage1691566572722v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 299.65 is automatically converting to 299.64.</title><link>https://community.appian.com/thread/117410?ContentTypeID=1</link><pubDate>Wed, 09 Aug 2023 04:50:59 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:21642d1e-1f1c-4ab8-b2b1-0ca15f220765</guid><dc:creator>deepakg271869</dc:creator><description>&lt;p&gt;Try to use fixed(ri!value,2) instead of&amp;nbsp;todecimal(fixed(trunc(ri!value, 2))) under value config.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 299.65 is automatically converting to 299.64.</title><link>https://community.appian.com/thread/117407?ContentTypeID=1</link><pubDate>Tue, 08 Aug 2023 18:43:25 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:07beff31-a7c7-4c9e-96b1-8975f98db55d</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;Yes, but I haven&amp;#39;t ran into any issues using fn!fixed (without fn!trunc), and I use it in a number of locations within a Purchase Request/Order application and elsewhere.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 299.65 is automatically converting to 299.64.</title><link>https://community.appian.com/thread/117406?ContentTypeID=1</link><pubDate>Tue, 08 Aug 2023 18:28:45 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:5e6aab6d-20ae-484e-b093-b13550a03bb3</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;You are aware that fixed() returns a string and you are back into an auto type conversion cycle?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 299.65 is automatically converting to 299.64.</title><link>https://community.appian.com/thread/117404?ContentTypeID=1</link><pubDate>Tue, 08 Aug 2023 16:29:48 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f59f06f5-44f4-4ca7-a5ea-0121ee62f388</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;I agree with fixed() only, and I would place the &amp;#39;conversion&amp;#39; on the saveInto vs the display, try:&lt;/p&gt;
&lt;p&gt;EDIT:&amp;nbsp; Code updated&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;a!floatingPointField(
  label: &amp;quot;Test&amp;quot;,
  value: ri!value,
  saveInto: a!save(
    ri!value,
    if(
      rule!APN_isEmpty(save!value),
      0.00,
      todecimal(fixed(save!value,2))
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 299.65 is automatically converting to 299.64.</title><link>https://community.appian.com/thread/117387?ContentTypeID=1</link><pubDate>Tue, 08 Aug 2023 13:14:38 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a09f4e5c-c4b9-4d1b-b7e6-86538f127628</guid><dc:creator>jamesm4933</dc:creator><description>&lt;p&gt;Fascinating bug you found there.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;From my testing, the issue seems to be with the trunc() function, fixed() does not exhibit the same behavior.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I recommend reducing your expression to: fixed(ri!value, 2)&lt;/p&gt;
&lt;p&gt;It is not necessary to use todecimal(), as the a!floatingPointField() performs the cast as well.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So, right now, you are truncating as a floating point number, converting to a string, and setting a fixed number of characters, then converting BACK to a floating point number, for a field than then casts to a floating point number automatically.&amp;nbsp; A few more steps than necessary, I should think.&lt;/p&gt;
&lt;p&gt;Take care,&lt;/p&gt;
&lt;p&gt;JM&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 299.65 is automatically converting to 299.64.</title><link>https://community.appian.com/thread/117386?ContentTypeID=1</link><pubDate>Tue, 08 Aug 2023 13:06:40 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:fbf18e37-e79f-4e1e-b3b2-3f7e188e172c</guid><dc:creator>Harshitha Mangamuri</dc:creator><description>&lt;p&gt;Can you please try this code which will solve your issue&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!floatingPointField(
label: &amp;quot;Test Decimal Value&amp;quot;,
value: todecimal(fixed(299.65,2))
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 299.65 is automatically converting to 299.64.</title><link>https://community.appian.com/thread/117385?ContentTypeID=1</link><pubDate>Tue, 08 Aug 2023 12:57:22 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:2a739758-88bf-4286-9646-d6ea7ca34d05</guid><dc:creator>ganesh_sasank18</dc:creator><description>&lt;p&gt;have you tried with trim()?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 299.65 is automatically converting to 299.64.</title><link>https://community.appian.com/thread/117384?ContentTypeID=1</link><pubDate>Tue, 08 Aug 2023 12:54:10 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c2cd61a7-fe12-4ddc-b26e-804a6ab7bb75</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;There is a general problem with how computers store decimal values. Check this:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.baeldung.com/cs/floating-point-numbers-inaccuracy"&gt;https://www.baeldung.com/cs/floating-point-numbers-inaccuracy&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You will see this with a lot of numbers. Depending in the internal representation it works most of the time and sometimes not. And there is no real fool proof way of managing this. Mathematical rounding should get you covered most of the time. This conversion to a string and back to a decimal will probably not.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 299.65 is automatically converting to 299.64.</title><link>https://community.appian.com/thread/117382?ContentTypeID=1</link><pubDate>Tue, 08 Aug 2023 12:51:13 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8fc4ff59-4582-4074-8fea-8f63d6b08eda</guid><dc:creator>shobhits6437</dc:creator><description>&lt;p&gt;Hi Harshitha,&lt;/p&gt;
&lt;p&gt;Thanks for the solution, but here we are passing both parameters of trunc function as rule inputs:&lt;br /&gt;&lt;img src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/13/pastedimage1691498943291v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 299.65 is automatically converting to 299.64.</title><link>https://community.appian.com/thread/117381?ContentTypeID=1</link><pubDate>Tue, 08 Aug 2023 12:48:52 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:80a24cdd-b29a-46b4-9a70-444d7c60b312</guid><dc:creator>shobhits6437</dc:creator><description>&lt;p&gt;Hi Stefan, Thanks for your reply. But, issue is it&amp;#39;s only happening with this specific number 2**.65 which is converting into 2**.64.&lt;/p&gt;
&lt;p&gt;It&amp;#39;s working with three decimal values, but business requirement is to keep up to two decimal values. And this is happening only in this scenario not with any other numbers. Like:&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/13/pastedimage1691499065028v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 299.65 is automatically converting to 299.64.</title><link>https://community.appian.com/thread/117380?ContentTypeID=1</link><pubDate>Tue, 08 Aug 2023 12:45:53 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8efaef7d-716f-4781-b028-3be661ca641b</guid><dc:creator>shobhits6437</dc:creator><description>&lt;p&gt;It&amp;#39;s working with three decimal values, but business requirement is to keep up to two decimal values. And this is happening only in this scenario not with any other numbers. Like:&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/13/pastedimage1691499086412v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 299.65 is automatically converting to 299.64.</title><link>https://community.appian.com/thread/117379?ContentTypeID=1</link><pubDate>Tue, 08 Aug 2023 12:45:37 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a0b6ad3b-9ec3-4ec3-b473-2a1bd86e4840</guid><dc:creator>Harshitha Mangamuri</dc:creator><description>&lt;p&gt;Hi, Please try to use this code which will give you 299.65&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!floatingPointField(
  label: &amp;quot;Test Decimal Value&amp;quot;,
  value: todecimal(fixed(trunc(299.65, 3))),
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 299.65 is automatically converting to 299.64.</title><link>https://community.appian.com/thread/117377?ContentTypeID=1</link><pubDate>Tue, 08 Aug 2023 12:40:59 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:4211fb5d-fdd5-4fe3-b0a2-f754209c015c</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;There is nothing &amp;quot;converted&amp;quot;. This is just the way how the values is displayed in both places.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 299.65 is automatically converting to 299.64.</title><link>https://community.appian.com/thread/117376?ContentTypeID=1</link><pubDate>Tue, 08 Aug 2023 12:40:51 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e64641d0-8bd9-4c53-8e0d-4d151c86df8f</guid><dc:creator>ganesh_sasank18</dc:creator><description>&lt;p&gt;is it necessary to truncate upto 2 decimals?once try with 3 decimals.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>