Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

convert string to double/float

Hi,
I got an issue where my source is delimiter file and it recognize a column as string in which it containing a value. I wants to convert from sting to double / float but it already rounded the value. I don't want it to be rounded. See example below:
INPUT
-------
0.00000215
0.00001645
After converting to double / float
OUTPUT
---------
0.000002
0.00002
EXPECTED OUTPUT
---------------------
0.00000215
0.00001645

Any idea? Please help me 0683p000009MPcz.png
Regards,
Kal
Labels (2)
6 Replies
Anonymous
Not applicable
Author

Hi,
Could you use tConvertType to achieve your goal?
Best regards
Sabrina
0683p000009MEMi.png 0683p000009MEUH.png
Anonymous
Not applicable
Author

Hi Sabrina,
I used exactly what you did. i got rounded decimal values. You can see the difference between VALUE_String and VALUE_Float as per below:

.------------+------------.
| tLogRow_1 |
|=-----------+-----------=|
|VALUE_string|VALUE_float |
|=-----------+-----------=|
|0.0000000000|0.0 |
|0.0000001000|0.0000001 |
|0.0000001000|0.0000001 |
|0.0000021500|0.000002 |
|0.0000021500|0.000002 |
|0.0000164500|0.00002 |
|0.0000164500|0.00002 |
|0.0000734000|0.00007 |
|0.0000734000|0.00007 |
|0.0004707000|0.0005 |
|0.0006008000|0.0006 |
|0.0006008000|0.0006 |
|0.0012983500|0.00129835 |
|0.0016000000|0.0016 |
|0.0024699000|0.0024699 |
|0.0039699000|0.0039699 |
|0.0054899000|0.0054899 |
|0.0067128000|0.0067128 |
|0.0087000000|0.0087 |
|0.0123961500|0.01239615 |
|0.0150000000|0.015 |
|0.0182337000|0.0182337 |
|0.0208000000|0.0208 |
|0.0225734000|0.0225734 |
|0.0251000000|0.0251 |
|0.0271793500|0.02717935 |
|0.0297519500|0.02975195 |
|0.0317519500|0.03175195 |
|0.0339575500|0.03395755 |
|0.0356000000|0.0356 |
I need to have the value exactly in float/double format since i wants to do some calculation. When the values already rounded then the end values of calculation will slightly inaccurate.
0683p000009MPcz.png
janhess
Creator II
Creator II

use Double.parseDouble(text) in a tMap rule or Float.parseFloat(text)
Anonymous
Not applicable
Author

Hi Janhess,
To used that way, the same output returned.
0683p000009MPcz.png
Anonymous
Not applicable
Author

Hi,
Could you please give us a screenshot of your workflow and the setting of your schema so that we can take a testing for your case.
Best regards
Sabrina
janhess
Creator II
Creator II

It's strange that only the first half of the results have been truncated.
Why don't you define the input as double in your input file schema.