First commit

This commit is contained in:
Wayne.MJ
2025-09-08 13:41:14 +10:00
commit df4d15d5c3
4 changed files with 119 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) [2025] [Wayne Jackson]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+13
View File
@@ -0,0 +1,13 @@
# sqrtnewton
This is a COBOL rewrite of a Fortran program that is a rewrite of a REXX script that I came across similar to the one on Wikipedia [Rexx](https://en.wikipedia.org/wiki/Rexx) to find the square root of a positive number.
I have modified the code to include:
- Correct for negative numbers
- Set a limit for iterations
- Set tolerances for 32 bit REAL numbers
- It also sanitises the input in case the user types something other than a number, also JES/JCL seems to not like numbers all that much being passed by SYSIN
This all came about as I am doing some courses on using the z/OS and writing code in REXX is one of the course modules.
I got bored.
+68
View File
@@ -0,0 +1,68 @@
IDENTIFICATION DIVISION.
* A rewrite of a fortran program that is rewrite of a REXX script
* to find the square root of a number
PROGRAM-ID. SQRNEWT.
AUTHOR. Wayne.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WORK-AREA.
05 MAX-ITER PIC 9(3) VALUE 100.
05 ITER PIC 9(3).
05 TOL PIC 9(3)V9(12) VALUE 0.0000000001.
05 RR PIC S9(3)V9(12).
05 R PIC S9(3)V9(12).
05 N PIC S9(3)V9(12).
05 N-TEXT PIC X(15).
05 DIS-RESULTS PIC Z(3).9(12).
PROCEDURE DIVISION.
DISPLAY "Enter a 3 digit value <> 0:"
* ACCEPT N FROM PARMS
* MOVE 4 TO N
ACCEPT N-TEXT
PERFORM VALID-INPUT
STOP RUN.
* Validate the input
* If less than 0 ie negative, make it positive
* If 0 then drop out
VALID-INPUT.
INSPECT N-TEXT REPLACING ALL "," BY "."
COMPUTE N = FUNCTION NUMVAL(N-TEXT)
* DISPLAY N
IF N LESS THAN ZERO THEN
COMPUTE N = N * (- 1)
DISPLAY "CORRECTED FOR NEGATIVE VALUE"
END-IF.
IF N NOT EQUAL ZERO THEN
PERFORM FIND-SQRROOT
ELSE
DISPLAY "CANNOT BE ZERO"
END-IF.
END-VALID-INPUT.
* Find the SQR Root of a number
FIND-SQRROOT.
MOVE 0 to ITER
MOVE 1 to R
PERFORM UNTIL ITER GREATER OR EQUAL MAX-ITER
COMPUTE ITER = ITER + 1
COMPUTE RR = (N / R + R) / 2
IF (FUNCTION ABS(RR - R) <= TOL) THEN
EXIT PERFORM
END-IF
MOVE RR TO R
END-PERFORM
MOVE RR TO DIS-RESULTS
DISPLAY DIS-RESULTS.
END-FIND-SQRROOT.
+17
View File
@@ -0,0 +1,17 @@
//SQRNEWT JOB 1,NOTIFY=&SYSUID
//***************************************************/
//COBRUN EXEC IGYWCL
//COBOL.SYSIN DD DSN=&SYSUID..CBL(SQRNEWT),DISP=SHR
//LKED.SYSLMOD DD DSN=&SYSUID..LOAD(SQRNEWT),DISP=SHR
//***************************************************/
// IF (RC = 0) THEN
//***************************************************/
//RUN EXEC PGM=SQRNEWT
//STEPLIB DD DSN=&SYSUID..LOAD,DISP=SHR
//SYSOUT DD SYSOUT=*
//SYSIN DD *
15
/*
//SYSUDUMP DD DUMMY
//***************************************************/
// ENDIF