sagobogger
Technical User
I have a datafile that includes dollar amounts. I want to only select the records where that $ amount is a multiple of another $ amount. I thought it would be simple to divide the first amount by the second and determine if the result is an integer;
DEFINE FILE MYFILE
NEWNUM/D8.2 = AMOUNT1/39.56;
INEWNUM/I8 = INT(NEWNUM);
ITSANINT/A1 = IF (NEWNUM - INEWNUM) EQ 0 THEN 'Y' ELSE 'N';
END
Doesn't work. Some values of NEWNUM e.g. the exact values 13.00 and 15.00 do not convert correctly to integers, 13 = 12 and 15.00 = 14.
If NEWNUM is defined as a P8.2 instead of a D8.2 it works, at least with the range of values I have seen so far, but maybe it will fail next month when there are new numbers?
It's not the case that the result of AMOUNT1/39.56 is not exact, if the amount is defined as a multiple e.g. 514.28 the result is the same.
Is there a better way to do this?
Is there an explanation for what's happening?
What are the format D vs P trade off's? I tend to use D's having had (or thought I had) some rounding issues with summing a lot of P's a long time ago.
WebFocus 4.3.6, source edit mode in MRE.
DEFINE FILE MYFILE
NEWNUM/D8.2 = AMOUNT1/39.56;
INEWNUM/I8 = INT(NEWNUM);
ITSANINT/A1 = IF (NEWNUM - INEWNUM) EQ 0 THEN 'Y' ELSE 'N';
END
Doesn't work. Some values of NEWNUM e.g. the exact values 13.00 and 15.00 do not convert correctly to integers, 13 = 12 and 15.00 = 14.
If NEWNUM is defined as a P8.2 instead of a D8.2 it works, at least with the range of values I have seen so far, but maybe it will fail next month when there are new numbers?
It's not the case that the result of AMOUNT1/39.56 is not exact, if the amount is defined as a multiple e.g. 514.28 the result is the same.
Is there a better way to do this?
Is there an explanation for what's happening?
What are the format D vs P trade off's? I tend to use D's having had (or thought I had) some rounding issues with summing a lot of P's a long time ago.
WebFocus 4.3.6, source edit mode in MRE.