next | previous | forward | backward | up | top | index | toc | Macaulay2 web site
Macaulay2Doc > The Macaulay2 language > strings and nets > format

format -- format a string or a real number

Description

Synopsis

  • Usage:
    format(s)
  • Inputs:
    • s
  • Outputs:
    • a string obtained from s by inserting escape sequences, thereby preparing it for printing in a form suitable for reading in again
i1 : s = "a\"b\"c"

o1 = a"b"c
i2 : t = format s

o2 = "a\"b\"c"
i3 : u = value t

o3 = a"b"c
i4 : u == s

o4 = true

Synopsis

  • Usage:
    format(s,k,l,t,e,x)
  • Inputs:
  • Outputs:
    • a string, the decimal representation of the number x, prepared according to the parameters above
i5 : format(10,1/3000.)

o5 = .0003333333333
i6 : format(10,6,1/3000.)

o6 = .000333
i7 : format(10,6,2,1/3000.)

o7 = 3.33e-4
i8 : format(10,300000.)

o8 = 300000
i9 : format(10,-1,10,5,300000.)

o9 = 300000
i10 : format(10,-1,10,4,300000.)

o10 = 3e5
i11 : format(10,-1,10,4,"E",300000.)

o11 = 3E5

See also