Write float arrays to a text file: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 1,776:
3,000E000 1,73205E000
1,000E011 3,16228E005
</pre>
 
=={{header|Vlang}}==
{{incomplete|Vlang|Formatting at least currently doesn't allow variables, floating point notation `g` seems to have bugs}}
<lang>import os
const (
x = [1.0, 2, 3, 1e11]
y = [1.0, 1.4142135623730951, 1.7320508075688772, 316227.76601683791]
xprecision = 3
yprecision = 5
)
fn main() {
if x.len != y.len {
println("x, y different length")
return
}
mut f := os.create("filename")?
defer {
f.close()
}
for i,_ in x {
f.write_string('${x[i]:3}, ${y[i]:1G}\n')?
}
}</lang>
{{out}}
<pre> 1, 1
2, 1.414
3, 1.732
1e+11, 316227.766
</pre>
 
338

edits