Floating Point Excel Output automatically rounding but need precision

Seven Stars

Floating Point Excel Output automatically rounding but need precision

I have a tMap with runs a calculation and stores it in a float variable before its outputted to excel. My problem is that the output appears as if its rounded but I can't figure out why

 

My calculation starts by adding 3 integers and stores that result in a variable "IntValue"

Var.IntValue is then divided it by both 11 and 12 and stores those in float variables Float11 & Float12 respectively. 

 

When I output Var.Float11 and Var.Float12 to a generic schema based output table to Columns of type float I get whole numbers (no decimal values) in both excel and csv file.

 

If I calculate the formula in Excel myself I get more expected values which include decimal places. 

 

Where in Talend am I going wrong that I don't get the same result? 


Accepted Solutions
Seven Stars

Re: Floating Point Excel Output automatically rounding but need precision

Also if add a tRowLog to output the flow the column in question is also a whole number 

 

My solution was to change the tMap Variable Counted from int to float (in the image attached earlier). That means the calculations where I divide by other numbers is based on a float as input instead of an integer value. I assumed only the end result needed to be floating and not the dividend. 


All Replies
Moderator

Re: Floating Point Excel Output automatically rounding but need precision

Hello,

Would you mind posting your tMap setting screenshots into forum?

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Seven Stars

Re: Floating Point Excel Output automatically rounding but need precision

Hi Sabrina,

 

Attached is the Variables Table and the output schema settings of the relevant tMap. Is that what you mean?

 

Seven Stars

Re: Floating Point Excel Output automatically rounding but need precision

Also if add a tRowLog to output the flow the column in question is also a whole number 

 

My solution was to change the tMap Variable Counted from int to float (in the image attached earlier). That means the calculations where I divide by other numbers is based on a float as input instead of an integer value. I assumed only the end result needed to be floating and not the dividend. 

Eleven Stars

Re: Floating Point Excel Output automatically rounding but need precision

use value like 11.0 instead of 11.

 

In Java , if you divide Int to Int , it will be rounded before Type Conversion.

 

check result of below commands 

 

System.out.println(11/10);
System.out.println(11/10.0);

Regards
Abhishek KUMAR

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Why Companies Move to the Cloud: 7 Success Stories

Learn how and why companies are moving to the Cloud

Read Now