<?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 Re: Help with BigDecimal/Double and writing Flat Files in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Help-with-BigDecimal-Double-and-writing-Flat-Files/m-p/2286058#M59680</link>
    <description>Thank you! This is helping me. I had to change it a bit for it to work. 
&lt;BR /&gt;
&lt;PRE&gt;row2.TKT_SALE_AMT.multiply(BigDecimal.valueOf(3.14))&lt;/PRE&gt;
&lt;BR /&gt;This is one step closer but not quite there for me. Here for a value of 4.47, I get output as 14.0358 which is correct but I need to round it to 2 decimals only (this will be 14.04). I looked at the MathContext but all the methods round the input to an integer (
&lt;A href="http://java.sun.com/j2se/1.5.0/docs/api/java/math/RoundingMode.html#HALF_EVEN" rel="nofollow noopener noreferrer"&gt;http://java.sun.com/j2se/1.5.0/docs/api/java/math/RoundingMode.html#HALF_EVEN&lt;/A&gt;). 
&lt;BR /&gt;If possible, let me know what I am missing here agian. 
&lt;BR /&gt;Thanks
&lt;BR /&gt;Sean</description>
    <pubDate>Fri, 27 Feb 2009 19:23:52 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2009-02-27T19:23:52Z</dc:date>
    <item>
      <title>Help with BigDecimal/Double and writing Flat Files</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Help-with-BigDecimal-Double-and-writing-Flat-Files/m-p/2286056#M59678</link>
      <description>Hello! 
&lt;BR /&gt;I'll appreciate some help from the forum members. 
&lt;BR /&gt;I am writing a simple routine that is reading from a CSV file that has a bunch of values such as sales, promotion $ etc. I've defined all of these as BigDecimal (12,2). I am new to Java but this is the type I read one should define currency values with. Then in a TMAP, I am doing a simple calculation such as Sales * 3.14. This gives me an error saying that "*" is incompatible with BigDecimal. Why is that? What is a work around? 
&lt;BR /&gt;I tried this with DOUBLE and it works but sometimes it gives me values such as 8.1200000001 in the flat file even though the output mask is DOUBLE(12,2). I expected it to be rounded or truncated at 2 decimal places. This probably is a simple question but I was not able to find a ROUND function that worked with BIG DECIMAL or DOUBLE and will round down to 2 decimal places. 
&lt;BR /&gt;I am used to Informatica which kind of shields me from the internals and has plentiful functions. In this case, I would have defined the output file as DECIMAL (12,2) and used High Precision to get my results or used the ROUND(Sales, 2). Note that I use Informatica at my job but I am a fan of Talend. Though I tend to compare these 2 quite a bit when it comes to usability etc. 
&lt;BR /&gt;Any insights are welcome. I am aware that I need to get familiar with Java &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; 
&lt;BR /&gt;Thanks. 
&lt;BR /&gt;Sean</description>
      <pubDate>Sat, 16 Nov 2024 14:03:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Help-with-BigDecimal-Double-and-writing-Flat-Files/m-p/2286056#M59678</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-16T14:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: Help with BigDecimal/Double and writing Flat Files</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Help-with-BigDecimal-Double-and-writing-Flat-Files/m-p/2286057#M59679</link>
      <description>Hi Sean, 
&lt;BR /&gt;calculating with Double or double is not a good idea if you work with money 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MA9p.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/138034i5F552429DA646D6F/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MA9p.png" alt="0683p000009MA9p.png" /&gt;&lt;/span&gt; 
&lt;BR /&gt;Looks like you used BigDecimal. To calculate with BigDecimal you could use for example: 
&lt;BR /&gt; 
&lt;PRE&gt;rowN.yourBigDecimal.multiply(3.14);&lt;/PRE&gt; 
&lt;BR /&gt;You can find more information in the 
&lt;A href="http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html" target="_blank" rel="nofollow noopener noreferrer"&gt;Java API BigDecimal&lt;/A&gt;. 
&lt;BR /&gt;Good practice in Java is to multiply your value with the number of internal decimal places and use an integer. 
&lt;BR /&gt;And you are right, the drawback of Talend's flexibility is that you have more knowledge about java (or perl). 
&lt;BR /&gt;Bye 
&lt;BR /&gt;Volker</description>
      <pubDate>Fri, 27 Feb 2009 10:36:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Help-with-BigDecimal-Double-and-writing-Flat-Files/m-p/2286057#M59679</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-02-27T10:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: Help with BigDecimal/Double and writing Flat Files</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Help-with-BigDecimal-Double-and-writing-Flat-Files/m-p/2286058#M59680</link>
      <description>Thank you! This is helping me. I had to change it a bit for it to work. 
&lt;BR /&gt;
&lt;PRE&gt;row2.TKT_SALE_AMT.multiply(BigDecimal.valueOf(3.14))&lt;/PRE&gt;
&lt;BR /&gt;This is one step closer but not quite there for me. Here for a value of 4.47, I get output as 14.0358 which is correct but I need to round it to 2 decimals only (this will be 14.04). I looked at the MathContext but all the methods round the input to an integer (
&lt;A href="http://java.sun.com/j2se/1.5.0/docs/api/java/math/RoundingMode.html#HALF_EVEN" rel="nofollow noopener noreferrer"&gt;http://java.sun.com/j2se/1.5.0/docs/api/java/math/RoundingMode.html#HALF_EVEN&lt;/A&gt;). 
&lt;BR /&gt;If possible, let me know what I am missing here agian. 
&lt;BR /&gt;Thanks
&lt;BR /&gt;Sean</description>
      <pubDate>Fri, 27 Feb 2009 19:23:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Help-with-BigDecimal-Double-and-writing-Flat-Files/m-p/2286058#M59680</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-02-27T19:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: Help with BigDecimal/Double and writing Flat Files</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Help-with-BigDecimal-Double-and-writing-Flat-Files/m-p/2286059#M59681</link>
      <description>Hi Sean,&lt;BR /&gt;take a look on the scale methods.&lt;BR /&gt;Bye&lt;BR /&gt;Volker</description>
      <pubDate>Fri, 27 Feb 2009 21:57:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Help-with-BigDecimal-Double-and-writing-Flat-Files/m-p/2286059#M59681</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-02-27T21:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: Help with BigDecimal/Double and writing Flat Files</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Help-with-BigDecimal-Double-and-writing-Flat-Files/m-p/2286060#M59682</link>
      <description>It took me some time to get it to work but I finally did it using the setscale method. &lt;BR /&gt;Thank you for your help. &lt;BR /&gt;Regards,&lt;BR /&gt;Sean</description>
      <pubDate>Sat, 28 Feb 2009 19:11:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Help-with-BigDecimal-Double-and-writing-Flat-Files/m-p/2286060#M59682</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-02-28T19:11:02Z</dc:date>
    </item>
  </channel>
</rss>

