Truncated Numbers

Question: I'm new at PL/I and have written a program. A simple X / 2 is doing some weird things. An example

X dec fixed(15) Y dec fixed(15,1)
Y = X/2

Now the problem is that this simple division is giving some weird results:

IF X = 1, Y = 0.0 (I would expect 0.5)


Answer: With those definitions, where X is set to 1 and the above code is run the following are the steps that are performed.:

To get the 0.5 you expect try

Y = X/2.0


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow