Nasal library: Difference between revisions

→‎sprintf(): Added some good examples for floating point width.
(→‎airportinfo(): Forgot one thing)
(→‎sprintf(): Added some good examples for floating point width.)
Line 606: Line 606:
! colspan="2" {{!}} Width
! colspan="2" {{!}} Width
{{!-}}
{{!-}}
{{!}} colspan="2" {{!}} Integer specifying the minimum number of characters to be returned.
{{!}} colspan="2" {{!}} Integer specifying the minimum number of characters to be returned. This includes the decimal point and decimal fraction.
{{!-}}
{{!-}}
! colspan="2" {{!}} Precision
! colspan="2" {{!}} Precision
Line 667: Line 667:
|example8 = print(sprintf("%o", 54)); # prints "66"
|example8 = print(sprintf("%o", 54)); # prints "66"
|example9 = print(sprintf("50%% of 100 is %i", 100 / 2)); # prints "50% of 100 is 50"
|example9 = print(sprintf("50%% of 100 is %i", 100 / 2)); # prints "50% of 100 is 50"
|example10 =
sprintf("%.2f", 1.4);  #prints "1.40"
sprintf("%.1f", 1.4);  #prints "1.4"
sprintf("% 4.1f", 1.4); #prints " 1.4"
sprintf("%04.1f", 1.4); #prints "01.4"
sprintf("% 6.1f", 1.4); #prints "  1.4"
sprintf("%06.1f", 1.4); #prints "0001.4"
}}
}}


574

edits