<?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: Cannot Convert from Float to BigDecimal Error: Tried with java syntax new BigDecimal. in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Cannot-Convert-from-Float-to-BigDecimal-Error-Tried-with-java/m-p/2366384#M129882</link>
    <description>&lt;P&gt;Hi there,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;There is no BigDecimal constructor which takes a Float, although there is one&amp;nbsp;which takes a Double,&amp;nbsp;and Java should automatically promote your Float to a Double when used within the constructor.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;You also need to consider what happens if your input value is null. Use&amp;nbsp;a ternary expression to return BigDecimal.ZERO instead, which for math purposes is likely to be what you'll want.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Be aware that converting from a Float to a BigDecimal will almost certainly not give you the exact value&amp;nbsp;you're expecting, due to lack of precision with the floating point data type.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;For example, if your input value is &lt;FONT face="courier new,courier"&gt;1.23f&lt;/FONT&gt;, then converting to a BigDecimal without specifying the precision will give you the value &lt;FONT face="courier new,courier"&gt;1.230000019073486328125&lt;/FONT&gt;, which probably isn't what you want. By&amp;nbsp;adding a&amp;nbsp;suitable MathContext to your BigDecimal constructor (e.g. &lt;FONT face="courier new,courier"&gt;new BigDecimal(floatIn, new java.math.MathContext(2))&lt;/FONT&gt;) you'll get &lt;FONT face="courier new,courier"&gt;1.23&lt;/FONT&gt;.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;All that said, as&amp;nbsp;&lt;A href="https://community.qlik.com/s/profile/00539000005OyYLAA0"&gt;@lli&lt;/A&gt;&amp;nbsp;says, it's still quite&amp;nbsp;possible that the error you're seeing is occurring elsewhere in the job, so click "Continue" on the error dialog, make a note of the line number given in the stack trace, then switch to the Code pane and check that the error is actually occurring on the expression within you tMap.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Regards,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Chris&lt;/P&gt;</description>
    <pubDate>Fri, 27 Oct 2017 14:56:14 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2017-10-27T14:56:14Z</dc:date>
    <item>
      <title>Cannot Convert from Float to BigDecimal Error: Tried with java syntax new BigDecimal.</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Cannot-Convert-from-Float-to-BigDecimal-Error-Tried-with-java/m-p/2366377#M129875</link>
      <description>&lt;P&gt;&amp;nbsp;Hi All,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I have got this error while loading data, I tried with java syntax new BigDecimal: Kindly help me.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Error: Cannot Convert from float to BigDecimal.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Talend Team Please comment on this.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Error.png" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009Lqyj.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/151039i7389567FE722902B/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009Lqyj.png" alt="0683p000009Lqyj.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Error_1.png" style="width: 724px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009LrDX.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/147675iFA4E2B6ECDD15749/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009LrDX.png" alt="0683p000009LrDX.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2017 13:21:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Cannot-Convert-from-Float-to-BigDecimal-Error-Tried-with-java/m-p/2366377#M129875</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-10-03T13:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Convert from Float to BigDecimal Error: Tried with java syntax new BigDecimal.</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Cannot-Convert-from-Float-to-BigDecimal-Error-Tried-with-java/m-p/2366378#M129876</link>
      <description>&lt;P&gt;I'm not sure the error is happening where you think it is. &amp;nbsp; Perhaps switch to the code view and see more info on where it's happening.&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Also, converting from a float to a BigDecimal isn't perfect since float is not an exact numeric. You may want to consider rounding to specific number of digits to get more exact. &amp;nbsp;What you show should compile, though.&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;&lt;SPAN class="kwd"&gt;new&lt;/SPAN&gt; &lt;SPAN class="typ"&gt;BigDecimal&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;field&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;, &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;new&lt;/SPAN&gt; &lt;SPAN class="typ"&gt;MathContext&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;3&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt; &lt;SPAN class="typ"&gt;RoundingMode&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;HALF_EVEN&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;))&lt;/SPAN&gt;&lt;/PRE&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2017 14:58:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Cannot-Convert-from-Float-to-BigDecimal-Error-Tried-with-java/m-p/2366378#M129876</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-10-03T14:58:33Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Convert from Float to BigDecimal Error: Tried with java syntax new BigDecimal.</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Cannot-Convert-from-Float-to-BigDecimal-Error-Tried-with-java/m-p/2366379#M129877</link>
      <description>&lt;P&gt;Thanks for reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code error is Exception with Type Mistmatch: Cannot convert Float to BigDecimal.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;tried our code too but error not resolved.&lt;/P&gt;&lt;P&gt;Request talend team to look into this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2017 16:13:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Cannot-Convert-from-Float-to-BigDecimal-Error-Tried-with-java/m-p/2366379#M129877</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-10-03T16:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Convert from Float to BigDecimal Error: Tried with java syntax new BigDecimal.</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Cannot-Convert-from-Float-to-BigDecimal-Error-Tried-with-java/m-p/2366380#M129878</link>
      <description>&lt;BLOCKQUOTE&gt; 
 &lt;HR /&gt; 
 &lt;A href="https://community.qlik.com/s/profile/0053p000007LMNJAA4"&gt;@mlorber&lt;/A&gt; wrote: 
 &lt;BR /&gt; 
 &lt;P&gt;&amp;nbsp;&lt;/P&gt; 
 &lt;P&gt;tried our code too but error not resolved.&amp;nbsp;&lt;/P&gt; 
 &lt;HR /&gt; 
&lt;/BLOCKQUOTE&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Hi, I think the error is occurring somewhere else in our job (not what you are showing in your screenshot). I was suggesting&amp;nbsp;to look at the code tab to see more specifically where the error is.&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2017 16:23:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Cannot-Convert-from-Float-to-BigDecimal-Error-Tried-with-java/m-p/2366380#M129878</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-10-03T16:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Convert from Float to BigDecimal Error: Tried with java syntax new BigDecimal.</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Cannot-Convert-from-Float-to-BigDecimal-Error-Tried-with-java/m-p/2366381#M129879</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have you used TypeConvert routine in Talend?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please try with &lt;STRONG&gt;TypeConvert.Float2BigDecimal(floatvalue)&amp;nbsp;&lt;/STRONG&gt; where floatvalue is the value from source and assign the output to Target.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Velu.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2017 08:02:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Cannot-Convert-from-Float-to-BigDecimal-Error-Tried-with-java/m-p/2366381#M129879</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-10-04T08:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Convert from Float to BigDecimal Error: Tried with java syntax new BigDecimal.</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Cannot-Convert-from-Float-to-BigDecimal-Error-Tried-with-java/m-p/2366382#M129880</link>
      <description>&lt;P&gt;Hi Velu,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Thanks for your reply, I'm getting same Type Mismatch error again no change at all with your expression.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Regards,&lt;/P&gt; 
&lt;P&gt;Jagadesh&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2017 10:50:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Cannot-Convert-from-Float-to-BigDecimal-Error-Tried-with-java/m-p/2366382#M129880</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-10-04T10:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Convert from Float to BigDecimal Error: Tried with java syntax new BigDecimal.</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Cannot-Convert-from-Float-to-BigDecimal-Error-Tried-with-java/m-p/2366383#M129881</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try converting with &lt;STRONG&gt;BigDecimal.valueOf(float) &lt;/STRONG&gt;to get the BigDecimal value&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Velu&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 18:58:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Cannot-Convert-from-Float-to-BigDecimal-Error-Tried-with-java/m-p/2366383#M129881</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-10-26T18:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Convert from Float to BigDecimal Error: Tried with java syntax new BigDecimal.</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Cannot-Convert-from-Float-to-BigDecimal-Error-Tried-with-java/m-p/2366384#M129882</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;There is no BigDecimal constructor which takes a Float, although there is one&amp;nbsp;which takes a Double,&amp;nbsp;and Java should automatically promote your Float to a Double when used within the constructor.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;You also need to consider what happens if your input value is null. Use&amp;nbsp;a ternary expression to return BigDecimal.ZERO instead, which for math purposes is likely to be what you'll want.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Be aware that converting from a Float to a BigDecimal will almost certainly not give you the exact value&amp;nbsp;you're expecting, due to lack of precision with the floating point data type.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;For example, if your input value is &lt;FONT face="courier new,courier"&gt;1.23f&lt;/FONT&gt;, then converting to a BigDecimal without specifying the precision will give you the value &lt;FONT face="courier new,courier"&gt;1.230000019073486328125&lt;/FONT&gt;, which probably isn't what you want. By&amp;nbsp;adding a&amp;nbsp;suitable MathContext to your BigDecimal constructor (e.g. &lt;FONT face="courier new,courier"&gt;new BigDecimal(floatIn, new java.math.MathContext(2))&lt;/FONT&gt;) you'll get &lt;FONT face="courier new,courier"&gt;1.23&lt;/FONT&gt;.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;All that said, as&amp;nbsp;&lt;A href="https://community.qlik.com/s/profile/00539000005OyYLAA0"&gt;@lli&lt;/A&gt;&amp;nbsp;says, it's still quite&amp;nbsp;possible that the error you're seeing is occurring elsewhere in the job, so click "Continue" on the error dialog, make a note of the line number given in the stack trace, then switch to the Code pane and check that the error is actually occurring on the expression within you tMap.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Regards,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2017 14:56:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Cannot-Convert-from-Float-to-BigDecimal-Error-Tried-with-java/m-p/2366384#M129882</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-10-27T14:56:14Z</dc:date>
    </item>
  </channel>
</rss>

