How to resolve the algorithm Write float arrays to a text file step by step in the M2000 Interpreter programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Write float arrays to a text file step by step in the M2000 Interpreter programming language

Table of Contents

Problem Statement

Write two equal-sized numerical arrays 'x' and 'y' to a two-column text file named 'filename'. The first column of the file contains values from an 'x'-array with a given 'xprecision', the second -- values from 'y'-array with 'yprecision'. For example, considering: The file should look like: This task is intended as a subtask for Measure relative performance of sorting algorithms implementations.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Write float arrays to a text file step by step in the M2000 Interpreter programming language

Source code in the m2000 programming language

Module Test1 (filename$, x, xprecision, y, yprecision) {
	locale 1033   // set decimal point symbol  to "."
	// using: for wide output   // for UTF16LE 
	// here we use ANSI (8bit per character)
	open filename$ for output as #f
	for i=0 to len(x)-1
		print #f, format$("{0} {1}", round(x#val(i),xprecision-1), round(y#val(i), yprecision-1))
	next
	close #f
	win "notepad", dir$+filename$
}
Test1 "OutFloat.num", (1, 2, 3, 1.e11),3,  (1, 1.4142135623730951, 1.7320508075688772, 316227.76601683791), 5

  

You may also check:How to resolve the algorithm Loops/Infinite step by step in the LDPL programming language
You may also check:How to resolve the algorithm Word wrap step by step in the jq programming language
You may also check:How to resolve the algorithm Angle difference between two bearings step by step in the Python programming language
You may also check:How to resolve the algorithm Ethiopian multiplication step by step in the Ursala programming language
You may also check:How to resolve the algorithm Program name step by step in the Racket programming language