[CLOSED] problem with dmod, fmod and imod in division
I have a value, for example 57, which I want to divide by 3. Obviously the answer is 19.
But I want to get a remainder to show me that my loop I would make 6 passes to edit 3 bytes each time to extract 18 bytes from this filed. Once I've extracted the 18 bytes, I will ignore the remaining 1 byte.
I tried the IMOD FUNCTION with smart dates ut I cannot get it with the numeric values.
-* File chk_mods.fex
DEFINE FILE CAR
MYDATE/YYMD WITH COUNTRY = &YYMD;
MYBASEDATE/YYMD = 20130101;
DAYSTHISYR/I5 = MYDATE - MYBASEDATE;
WEEKNUMBER/I4 = DAYSTHISYR/7;
DAYSINTOWK/I4 = IMOD(DAYSTHISYR,7,'I4');
D1/I2=57;
D2/I2=3;
D123/D20.2 = (D1/D2);
DXX3/I4 = IMOD(D1,D2,'I4');
END
TABLE FILE CAR
PRINT
MYDATE
MYBASEDATE
DAYSTHISYR
WEEKNUMBER
DAYSINTOWK
D1
D2
D123
DXX3
BY COUNTRY
END
-RUN
I have printed and read the IMOD, DMOD and FMOD documentation but No result.
I'm optimistic I can do this in dialogue manager and see the decimal places.
Any ideas?
ThanksThis message has been edited. Last edited by: <Kathryn Henning>,
Try SET DMPRECISION = number; with the number being the number of decimal places you want to see.
WF 8.1.05 on Windows machines Backend: Informix, SQL and Oracle databases
April 18, 2013, 04:40 PM
Crymsyn
I do not think I understand what you are trying to do with modular division so sorry if you know this.
Modular division only shows the remainder in a whole number instead of a decimal. In your case 57 / 3 has no remainder so you will get 0 as the code you showed suggests.
If you want to get 6 from 19 could do the following but you do not need modular division. There is also the INT function that always rounds down to the lowest whole number.
D4/I4=D123/D2;
If none of that helped could you explain it in a different way and/or show more examples of what you have and what it should look like?