Skip to content
Related Articles

Related Articles

Improve Article

Convert an Integer to a String in Julia – string() Function

  • Last Updated : 26 Mar, 2020

The string() is an inbuilt function in julia which is used to convert a specified integer to a string in the given base.

Syntax:
string(n::Integer; base::Integer, pad::Integer)

Parameters:

  • n::Integer: Specified integer.
  • base::Integer: Specified base in which convertion are going to be performed.

    Optional parameter:

  • pad::Integer: It is number of characters present in the returned string.

Returns: It returns the converted string in the given base.



Example 1:




# Julia program to illustrate 
# the use of String string() method
   
# Convertion of integer to a string
# in the given base
Println(string(10, base = 5, pad = 5))
Println(string(10, base = 5, pad = 3))
Println(string(5, base = 10, pad = 2))
Println(string(8, base = 9, pad = 4))

Output:

 :
Example 2:




# Julia program to illustrate 
# the use of String string() method
   
# Creation of a single string using
# all the aruguments 
Println(string("A", 5, true))
Println(string("A", 10, false))
Println(string("B", 6, true))
Println(string("C", 12, false))

Output:

My Personal Notes arrow_drop_up
Recommended Articles
Page :