RonKoontz
1355 pts. | May 13 2009 4:17PM GMT
That will work and I’m doing that for now. But I wanted to use %replace just for fun. I do that lots…lol
DanTheDane
245 pts. | May 16 2009 7:41PM GMT
In the ‘old days’ with RPGII is was recommended not to do a division in a case like this; - us multiply instead … (reasons: less proces to do the task !!! and smaller objectcode !!! ).
In todays freeform:
result = indata * .01;
result: 5.2
indata: 7.0
RonKoontz
1355 pts. | May 18 2009 12:19PM GMT
I more want to basically replace the decimal position with something else. I have some logic that I will need to do this based on 1/4’s. I can use %replace to a numeric or alpha field but I can not get it to work with a decimal field. Thats kind of what I wanted to do. I want to do it with one line of code instead of 2 or three. Thanks
Yorkshireman
3200 pts. | May 20 2009 7:34AM GMT
Just so that I understand
you want a line of code which will convert
In=1234512
into
New= 12345.12
and the line
new = In * 0.01
is not adequate?
But surely, anyone who subsequently has to read and maintain the code will instantly interpret the line and understand what’s going on, whereas achieving the same answer via a circuitous and obscure line of code is sowing doubt and confusion for the future.. - We’ve all been there - “Look at this, what’s it doing? - A reverse back integer logical OR with bitwise transgression - that must be there for a deep and meaningful purpose. . . clock ticks by .. . but all I can see it doing is multiply A * B ”
OTOH, I find this stuff fascinating, and if it’s for your personal fund of adventures in code, more power to your pencil.
Yorkshireman
hoping you’ll publish the final solution
RonKoontz
1355 pts. | May 20 2009 12:03PM GMT
Yes that works… But………Lets say I want to change the decimal position to .25 or .50 or .75 or .00. I could run this through a loop to add one or subtract the 2 and then add that amount to it.
All I want to do is replace the decimal part of the number.
Lots of it is for personal interest but other is to keep it simple and a one liner…
This also may be usefull to someone else in th future.
I like interesting code solutions and I will post it as soon as a find a good solution.
Thanks
BigKat
2540 pts. | May 20 2009 2:22PM GMT
This is a good place place for a … service program.
one-liner call in the program, but I doubt you will be able to do something so complex as rounding to the nearest 0.25 in one line, so tuck the code away in the service program






