gasomma Member May 20, 2011 #1 Hello, I tried searching but i didnt find anything that would help me with my situation so here is my question... I want to separate in two different integer fields a decimal value. Ex. value=6.73 field1 = 6 field2 = 73 have in 4gl a function for that? Thx JCA
Hello, I tried searching but i didnt find anything that would help me with my situation so here is my question... I want to separate in two different integer fields a decimal value. Ex. value=6.73 field1 = 6 field2 = 73 have in 4gl a function for that? Thx JCA
T tommartinson Member May 20, 2011 #2 This seems to do what you are asking: def var decnum as dec init 56.3. disp int(truncate(decnum,0)) int( ((decnum - truncate(decnum,0)) * 100) ) .
This seems to do what you are asking: def var decnum as dec init 56.3. disp int(truncate(decnum,0)) int( ((decnum - truncate(decnum,0)) * 100) ) .
jdpjamesp ProgressTalk.com Moderator Staff member May 23, 2011 #4 Alternatively disp int(entry(1,string(decnum),".")) int(entry(2,string(decnum),".")). should work.
Stefan Well-Known Member May 23, 2011 #5 Cringer said: Alternatively disp int(entry(1,string(decnum),".")) int(entry(2,string(decnum),".")). should work. Click to expand... Actually it depends. You are assuming that the decimal point is a point, you can easily remove the assumption with: Code: disp int(entry(1,string(decnum),SESSION:NUMERIC-DECIMAL-POINT)) int(entry(2,string(decnum),SESSION:NUMERIC-DECIMAL-POINT)). Then you run into the next assumption that the decimal will always have a decimal part. Which can then be worked around: Code: disp int(entry(1,string(decnum),SESSION:NUMERIC-DECIMAL-POINT)) int(if num-entries( string( decnum ), session:numeric-point ) = 2 then entry(2,string(decnum),SESSION:NUMERIC-DECIMAL-POINT) else 0 ). But its a bit of a mess, so I'd stick to much cleaner truncate version.
Cringer said: Alternatively disp int(entry(1,string(decnum),".")) int(entry(2,string(decnum),".")). should work. Click to expand... Actually it depends. You are assuming that the decimal point is a point, you can easily remove the assumption with: Code: disp int(entry(1,string(decnum),SESSION:NUMERIC-DECIMAL-POINT)) int(entry(2,string(decnum),SESSION:NUMERIC-DECIMAL-POINT)). Then you run into the next assumption that the decimal will always have a decimal part. Which can then be worked around: Code: disp int(entry(1,string(decnum),SESSION:NUMERIC-DECIMAL-POINT)) int(if num-entries( string( decnum ), session:numeric-point ) = 2 then entry(2,string(decnum),SESSION:NUMERIC-DECIMAL-POINT) else 0 ). But its a bit of a mess, so I'd stick to much cleaner truncate version.