Hi,
In a specific protocol, our client ask to send data without decimal, a number of 33,98 I have to convert it into (339800000), and in output I didn't have any problem, but in input this is converted to float and when I divide my number from (339800000) to 33,98 I receive a float like 33.979999999999996.
here's my sample program:
**free
Ctl-Opt DftActGrp(*no)
ActGrp(*StgMdl)
StgMdl(*SNGLVL)
BndDir('AL400MNUV2')
Thread(*Concurrent)
Option(*NoUnRef :*SrcStmt :*NoDebugIo)
DatFmt(*Iso) TimFmt(*Iso)
Debug(*Constants)
AlwNull(*UsrCtl)
FltDiv(*yes)
DftName(TESTDEC)
Text('Test decimali');
// ________________________________________________________
// Campi di work
Dcl-S PrezzoChar Char(20) Inz('339800000');
Dcl-S PrezzoDec Packed(30:15);
Dcl-S PrezzoFloat Float(8);
Dcl-Pr DspLongMsg ExtPgm('QUILNGTX');
Text Char(16773100) const options(*varsize);
Length Int(10) Const;
Msgid Char(7) Const;
Qualmsgf Char(20) Const;
ErrorCode Char(32767) options(*varsize);
End-Pr DspLongMsg;
Dcl-Ds ApiError Qualified;
BytPrv Int(10) Inz(%Size(ApiError));
BytAvl Int(10) Inz(0);
MsgId Char(7);
*n Char(1);
MsgDta Char(128);
End-Ds ApiError;
Dcl-Ds TextMsg;
TextArr Char(80) Dim(24);
End-Ds TextMsg;
// ___________________________________________________________________________
PrezzoDec = %Dec(PrezzoChar : 30 :15) / (10**7);
PrezzoFloat = %Int(PrezzoChar) / (10**7);
PrezzoDec = %Dec(PrezzoFloat :30 :15) ;
TextArr(1) = 'Prezzo Float: ' + %Char(PrezzoFloat);
TextArr(2) = 'Prezzo Dec : ' + %Char(PrezzoDec);
DspLongMsg(TextMsg:%Len(TextMsg):'':'':ApiError);
Return;
I try the H spec FLTDIV, but it seems there's no effect...
Anyone have a solution?
Many thanks.
------------------------------
Paolo Salvatore
------------------------------
#RPG