Re: Newbie Question
- From: "Oliver Wong" <owong@xxxxxxxxxxxxxx>
- Date: Wed, 31 May 2006 17:53:26 GMT
"Michael Mattias" <michael.mattias@xxxxxxx> wrote in message news:chkfg.2708$VE1.1350@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
"Oliver Wong" <owong@xxxxxxxxxxxxxx> wrote in message
news:S1kfg.223$I61.46@xxxxxxxxxxx
It takes 34 bits to store an unsigned 10 digit number, and 35 bits to
store a signed 10 digit number, so you're right that LONG INTEGER (32 bit
signed) won't be enough to store all values of the PIC 9(10). However, if
you move to floating point numbers (e.g. SINGLE or DOUBLE), you're opening
yourself up to problems with rounding, which may also yield big headaches.
What additional problems could there be ..considering this application was
already MOVEing a PIC 9(10) field to a PIC 9(1) field.... seems to me any
rounding problems introduced with floating point numbers are kind of
immaterial .....
Perhaps the code in which the MOVE occurs never gets executed (e.g. it's dead code after a lot of maintenance has happened). Hard to say without seeing the rest of the program. IMHO, the VB code that you produce should behave EXACTLY the same as the COBOL code. If you spot a bug in the COBOL code, make a note of it, but replicate that bug in your VB code as well. During the translation process is NOT the time to be making bug fixes. Only later, once your code has been translated, can you start using tools from your target language (e.g. adding unit tests or whatever) and fixing bugs, AFTER you've ensured that your resulting VB code is exactly equivalent to the original COBOL code.
(Besides, a DOUBLE has 16 decimal digits of precision).
I think the following pair of 16 digit numbers have the same represensation in IEEE 64 bit double: 9'007'199'254'740'992 and 9'007'199'254'740'993. I'll concede that double has at least 15 digits of precision, and the OP only needs 10, but...
IMHO, using double would obfuscate what's going on here and confuse the maintance programmer, especially if exact comparisons between doubles are performed later on:
<code>
DIM var1, var2 AS DOUBLE
.... some code which assigns to var ...
IF var1 == var2 THEN
do something
END IF
</code>
a maintenance programmer might see this as a bug and be tempted to refactor it to
<code>
DIM var1, var2 AS DOUBLE
.... some code which assigns to var ...
CONST EPSILON = 0.001
IF Math.ABS(var1 - var2) < EPSILON THEN
do something
END IF
</code>
And then there's that whole abusing-the-type-system issue...
Ideally, the OP would take the BigInteger source code and modify it so that it limits itself to values which, when expressed in decimal, are 10 digits long (thus mimicking the PIC 9(10) more accurately in the case of overflow and truncation), but that may be overkill.
- Oliver
.
- Follow-Ups:
- Re: Newbie Question
- From: Michael Mattias
- Re: Newbie Question
- References:
- Newbie Question
- From: the_tragic_hip
- Re: Newbie Question
- From: Michael Mattias
- Re: Newbie Question
- From: Oliver Wong
- Re: Newbie Question
- From: Michael Mattias
- Newbie Question
- Prev by Date: Re: PIC P put to real use
- Next by Date: Re: Newbie Question
- Previous by thread: Re: Newbie Question
- Next by thread: Re: Newbie Question
- Index(es):
Relevant Pages
|
|