How to resolve the algorithm Non-decimal radices/Output step by step in the Wren programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Non-decimal radices/Output step by step in the Wren programming language

Table of Contents

Problem Statement

Programming languages often have built-in routines to convert a non-negative integer for printing in different number bases. Such common number bases might include binary, Octal and Hexadecimal.

Print a small range of integers in some different bases, as supported by standard routines of your programming language.

This is distinct from Number base conversion as a user-defined conversion function is not asked for.) The reverse operation is Common number base parsing.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Non-decimal radices/Output step by step in the Wren programming language

Source code in the wren programming language

import "/fmt" for Conv, Fmt

System.print("     2    7    8   10   12   16   32")
System.print("------ ---- ---- ---- ---- ---- ----")
for (i in 1..33) {
    var b2  = Fmt.b(6, i)
    var b7  = Fmt.s(4, Conv.itoa(i, 7))
    var b8  = Fmt.o(4, i)
    var b10 = Fmt.d(4, i)
    var b12 = Fmt.s(4, Conv.Itoa(i, 12))
    var b16 = Fmt.X(4, i)
    var b32 = Fmt.s(4, Conv.Itoa(i, 32))
    System.print("%(b2) %(b7) %(b8) %(b10) %(b12) %(b16) %(b32)")
}

  

You may also check:How to resolve the algorithm Roots of a quadratic function step by step in the R programming language
You may also check:How to resolve the algorithm Text processing/Max licenses in use step by step in the R programming language
You may also check:How to resolve the algorithm Penney's game step by step in the Java programming language
You may also check:How to resolve the algorithm Function definition step by step in the UNIX Shell programming language
You may also check:How to resolve the algorithm Program termination step by step in the Oforth programming language