How to resolve the algorithm Formatted numeric output step by step in the Seed7 programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Formatted numeric output step by step in the Seed7 programming language

Table of Contents

Problem Statement

Express a number in decimal as a fixed-length string with leading zeros.

For example, the number   7.125   could be expressed as   00007.125.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Formatted numeric output step by step in the Seed7 programming language

Source code in the seed7 programming language

$ include "seed7_05.s7i";
  include "float.s7i";

const proc: main is func
  local
    const float: r is 7.125;
  begin
    writeln( r digits 3 lpad 9);
    writeln(-r digits 3 lpad 9);
    writeln( r digits 3 lpad0 9);
    writeln(-r digits 3 lpad0 9);
    writeln( r digits 3);
    writeln(-r digits 3);
  end func;

  

You may also check:How to resolve the algorithm Conjugate transpose step by step in the ALGOL 68 programming language
You may also check:How to resolve the algorithm Jewels and stones step by step in the AutoHotkey programming language
You may also check:How to resolve the algorithm Multiplicative order step by step in the ALGOL 68 programming language
You may also check:How to resolve the algorithm A+B step by step in the CFEngine programming language
You may also check:How to resolve the algorithm Minkowski question-mark function step by step in the Go programming language