Decimal conserve

Hello!
Is it possible to keep decimals in a value which you save in a variable like .toString?

Yes, I believe so. If the original variable has a decimal then .toString will just make it to a string variable but will keep whatever is in the original variable

Yes, the original variable is int32, but when I pass it to .toString it approximates and removes the decimals

I might be wrong, but if I remember it right int32 does not have decimals. Your number variable has to be a double for it to have decimals.

1 Like

I’ll try to change you to double, thanks

1 Like

@Beatriz_Eugenia_Duqu

You can check my response in newly posted post

Use Format Values activity

Thanks

1 Like

Help Please!

@Beatriz_Eugenia_Duqu
it looks that this topic is duplicate of your other Post:

so tell us from where the value is coming from and in which form/dataformat
so far as understood e.g. if the value has decimals (2.34) so in its string representation is still has to keep it, right?

1 Like

Formato

@Beatriz_Eugenia_Duqu
Perfect, so it looks like the data source is EXCEL and we assume you did read range into a datatable.
so based on a datarow a yourDataRowVar(ColumnNameOrIndex).toString should not lose the decimals. Maybe the output is different from the expected formatings.

with a quick look into the datatable (Debugging, set Breakpoint, Locals Panel) you can check out for us on what is read in using which format

once we do know we can decide on solution approach (toString formatting, Double parsing …)

2 Likes

I put the data output in double, try int32, with string,
None of the above worked, it always approximates the value
Thanks

@Beatriz_Eugenia_Duqu Is it possible for you to share that excel data, or share the Screenshots of how you are trying to get the value?

Nuevo.xlsx (11.1 KB)

@Beatriz_Eugenia_Duqu When you tried to read the First Column First row value using the Datatable variable, What value did you get ?

@Beatriz_Eugenia_Duqu
Have you tried this…?
Convert.ToDouble(row(0).ToString).ToString("#.##")

Sorry but i don’t understand the question

I will try this method
Thanks