Write float arrays to a text file: Difference between revisions
Content deleted Content added
→{{header|Vlang}}: Rename "Vlang" in "V (Vlang)" |
No edit summary |
||
Line 666: | Line 666: | ||
1E+11 3.1623E+05 |
1E+11 3.1623E+05 |
||
</pre> |
</pre> |
||
=={{header|FutureBasic}}== |
|||
<syntaxhighlight lang="futurebasic"> |
|||
local fn DoIt |
|||
NSUInteger i |
|||
CFStringRef s |
|||
CFArrayRef x = @[@1, @2, @3, @1e11] |
|||
CFArrayRef y = @[@1, @1.4142135623730951, @1.7320508075688772, @316227.76601683791] |
|||
CFMutableStringRef mutStr = fn MutableStringWithCapacity(0) |
|||
CFURLRef desktopURL = fn FileManagerURLForDirectory( NSDesktopDirectory, NSUserDomainMask ) |
|||
CFURLRef url = fn URLByAppendingPathComponent( desktopURL, @"Array_to_file.txt" ) |
|||
for i = 0 to 3 |
|||
if ( i < 3 ) |
|||
s = fn StringWithFormat( @"%ld \t", fn NumberIntegerValue( x[i] ) ) |
|||
MutableStringAppendString( mutStr, s ) |
|||
s = fn StringWithFormat( @"%.4f\n", fn NumberFloatValue( y[i] ) ) |
|||
MutableStringAppendString( mutStr, s ) |
|||
else |
|||
s = fn StringWithFormat( @"%.e\t", fn NumberFloatValue( x[i] ) ) |
|||
MutableStringAppendString( mutStr, s ) |
|||
s = fn StringWithFormat( @"%.4e\n", fn NumberFloatValue( y[i] ) ) |
|||
MutableStringAppendString( mutStr, s ) |
|||
end if |
|||
next |
|||
fn StringWriteToURL( mutStr, url, YES, NSUTF8StringEncoding, NULL ) |
|||
print mutStr |
|||
end fn |
|||
fn DoIt |
|||
HandleEven |
|||
</syntaxhighlight> |
|||
{{output}} |
|||
<pre> |
|||
1 1.0000 |
|||
2 1.4142 |
|||
3 1.7321 |
|||
1e+11 3.1623e+05 |
|||
</pre> |
|||
=={{header|Go}}== |
=={{header|Go}}== |