To answer myself, "Yes, but"
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 FLOATER PIC 9(8)V9(8).
01 SINKER REDEFINES FLOATER.
03 LEFTOF PIC 9(8).
03 RIGHTOF PIC 9(8).
PROCEDURE DIVISION.
INITIALIZE SINKER.
MOVE 123.456789 TO FLOATER.
DISPLAY LEFTOF.
DISPLAY RIGHTOF.
STOP RUN.
00000123
45678900
Is there a better way?
...I'm still thinking about the UNSTRING but in the interim I found INTEGER-PART and FRACTION-PART.
On Saturday, 14 January 2023 at 9:38:23 pm UTC+8, Rick Smith wrote:
...I'm still thinking about the UNSTRING but in the interim I found INTEGER-PART and FRACTION-PART.
Clearly, I'm doing something wrong here.
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 FLOATER PIC 9(8)V9(8).
01 LEFTOF PIC 9(8).
01 RIGHTOF PIC 9(8).
PROCEDURE DIVISION.
MOVE 123.456789 TO FLOATER.
MOVE FUNCTION INTEGER-PART(FLOATER) TO LEFTOF.
MOVE FUNCTION FRACTION-PART(FLOATER) TO RIGHTOF.
DISPLAY LEFTOF " . " RIGHTOF.
STOP RUN.
00000123 . 00000000
On Saturday, 14 January 2023 at 9:38:23 pm UTC+8, Rick Smith wrote:
...I'm still thinking about the UNSTRING but in the interim I found INTEGER-PART and FRACTION-PART.
Clearly, I'm doing something wrong here.
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 FLOATER PIC 9(8)V9(8).
01 LEFTOF PIC 9(8).
01 RIGHTOF PIC 9(8).
PROCEDURE DIVISION.
MOVE 123.456789 TO FLOATER.
MOVE FUNCTION INTEGER-PART(FLOATER) TO LEFTOF.
MOVE FUNCTION FRACTION-PART(FLOATER) TO RIGHTOF.
DISPLAY LEFTOF " . " RIGHTOF.
STOP RUN.
00000123 . 00000000
To answer myself, "Yes, but"
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 FLOATER PIC 9(8)V9(8).
01 SINKER REDEFINES FLOATER.
03 LEFTOF PIC 9(8).
03 RIGHTOF PIC 9(8).
PROCEDURE DIVISION.
INITIALIZE SINKER.
MOVE 123.456789 TO FLOATER.
DISPLAY LEFTOF.
DISPLAY RIGHTOF.
STOP RUN.
00000123
45678900
Is there a better way?
On Saturday, 14 January 2023 at 9:38:23 pm UTC+8, Rick Smith wrote:
...I'm still thinking about the UNSTRING but in the interim I found INTEGER-PART and FRACTION-PART.
Clearly, I'm doing something wrong here.
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 FLOATER PIC 9(8)V9(8).
01 LEFTOF PIC 9(8).
01 RIGHTOF PIC 9(8).
PROCEDURE DIVISION.
MOVE 123.456789 TO FLOATER.
MOVE FUNCTION INTEGER-PART(FLOATER) TO LEFTOF.
MOVE FUNCTION FRACTION-PART(FLOATER) TO RIGHTOF.
DISPLAY LEFTOF " . " RIGHTOF.
STOP RUN.
00000123 . 00000000
In article <f8eb7b04-7406-462c...@googlegroups.com>,
Bruce Axtens <bruce....@gmail.com> wrote:
What'cha lookin'a do?
Hello Bruce!
GnuCobol Programmers Reference and Guide has been updated accordingly. > Vincent
On Sunday, 15 January 2023 at 11:58:17 pm UTC+8, docd...@panix.com wrote:
In article <f8eb7b04-7406-462c...@googlegroups.com>,
Bruce Axtens <bruce....@gmail.com> wrote:
What'cha lookin'a do?
I wanted to split a floating point number into two integers being the
left of decimal point and the right of decimal point. Even as I typed
that I started to wonder: if 123.456 gets split into 123 and 456, what
does the 456 actually represent? It certainly doesn't represent four
hundred and fifty six.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 300 |
Nodes: | 16 (2 / 14) |
Uptime: | 106:25:59 |
Calls: | 6,700 |
Files: | 12,232 |
Messages: | 5,350,363 |