‎2014 Feb 19 2:01 PM
Hiya,
I have the following table field:
I'd like to use the contents of it to do some calculations but the value always appears slightly odd.
I mean if I read and write the value to screen I get the following:
When I would have expected it to show 12.33
Can anyone help me understand what I might be doing wrong please?
Many thanks!
‎2014 Feb 19 2:05 PM
‎2014 Feb 19 2:05 PM
‎2014 Feb 19 2:12 PM
Thanks Miguel1
That was helpful but I'd like to do some calculations with the floating point number and I don't think Char fields are recommended for calculations..
Or do you think I should do this:
-Get the floating point number from the table.
-CALL FUNCTION 'CEVA_CONVERT_FLOAT_TO_CHAR' to convert the number into a character.
-Move the number from the character field into a NUMC field(?) and then do my calculations with that value?
What do you reckon?
‎2014 Feb 19 2:14 PM
Hi.
it is easier to move a char to a numc to do calculations. So half way it is done using that FM.
Regards
Miguel
‎2014 Feb 19 2:23 PM
Thansk Miguel.
I think the problem with that function module is that it expects you to know how many decimal places you would expect - via the FORMAT_IMP parameter.
For me that number could be variable....
Don't really know what to do now.
‎2014 Feb 19 2:28 PM
Hi,
Yes, as u said, u need to show just 2 decimals...12.33
so all the numbers will be showed with 2 decimals...
check the FM in development system and so dome calculation, maybe it will work.
Regards
Miguel
‎2014 Feb 19 2:35 PM
Why don't you want to use the FLOAT for calculations? If you fear rounding errors just move the value to a DEC field.
‎2014 Feb 19 3:23 PM
Hi Uwe,
Sorry I'm new to floating point numbers and I'm finding them a little scary. I'm probably asking lots of stupid questions but what you write makes sense.
-Do the calculation with the floating point number.
I'm doing a total for a currency field field with 2 decimal points:
Once I've done my calculation would it be okay (i.e. good practice) to simply move my value into this field?
Or even to use this field directly in the calculation i.e.
LV_TOTAL_COST = LV_TOTAL_COST * Floating_point_value
Sorry if my questions sound stupid but I want to follow vbest practice when coding.
Many thanks!
‎2014 Feb 19 7:41 PM
Hi Robert,
there are no stupid questions (mostly), just stupid answers.
Floats are not scary, just the scientific representations of values. You probably know the meaning of 1.234 * 105
And yes, you can use LV_TOTAL_COST = LV_TOTAL_COST * Floating_point_value.