[658f6de0] | 1 | // -*- Mode: C -*- |
---|
| 2 | // |
---|
| 3 | // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo |
---|
| 4 | // |
---|
| 5 | // The contents of this file are covered under the licence agreement in the |
---|
| 6 | // file "LICENCE" distributed with Cforall. |
---|
| 7 | // |
---|
| 8 | // ato.c -- |
---|
| 9 | // |
---|
| 10 | // Author : Peter A. Buhr |
---|
| 11 | // Created On : Thu Feb 4 08:10:57 2016 |
---|
| 12 | // Last Modified By : Peter A. Buhr |
---|
[90c3b1c] | 13 | // Last Modified On : Mon Feb 29 17:57:35 2016 |
---|
| 14 | // Update Count : 44 |
---|
[658f6de0] | 15 | // |
---|
| 16 | |
---|
| 17 | #include <fstream> |
---|
| 18 | #include <stdlib> // ato, strto |
---|
| 19 | extern "C" { |
---|
| 20 | #include <stdio.h> |
---|
| 21 | #include <float.h> |
---|
| 22 | } |
---|
| 23 | |
---|
| 24 | int main( void ) { |
---|
| 25 | int i = ato( "-123" ); |
---|
[90c3b1c] | 26 | sout | i | "-123" | endl; |
---|
[658f6de0] | 27 | unsigned int ui = ato( "123" ); |
---|
[90c3b1c] | 28 | sout | ui | "123" | endl; |
---|
[658f6de0] | 29 | long int li = ato( "-123" ); |
---|
[90c3b1c] | 30 | sout | li | "-123" | endl; |
---|
[658f6de0] | 31 | unsigned long int uli = ato( "123" ); |
---|
[90c3b1c] | 32 | sout | uli | "123" | endl; |
---|
[658f6de0] | 33 | long long int lli = ato( "-123" ); |
---|
[90c3b1c] | 34 | sout | lli | "-123" | endl; |
---|
[658f6de0] | 35 | unsigned long long int ulli = ato( "123" ); |
---|
[90c3b1c] | 36 | sout | ulli | "123" | endl; |
---|
[658f6de0] | 37 | float f = ato( "-123.456" ); |
---|
[90c3b1c] | 38 | sout | f | "-123.456" | endl; |
---|
[658f6de0] | 39 | double d = ato( "-123.4567890123456" ); |
---|
[90c3b1c] | 40 | sout | d | "-123.4567890123456" | endl; |
---|
[658f6de0] | 41 | long double ld = ato( "-123.45678901234567890123456789" ); |
---|
[90c3b1c] | 42 | sout | ld | "-123.45678901234567890123456789" | endl; |
---|
[658f6de0] | 43 | float _Complex fc = ato( "-123.456-123.456i" ); |
---|
[90c3b1c] | 44 | sout | fc | "-123.456-123.456i" | endl; |
---|
[658f6de0] | 45 | double _Complex dc = ato( "-123.4567890123456+123.4567890123456i" ); |
---|
[90c3b1c] | 46 | sout | dc | "-123.4567890123456+123.4567890123456i" | endl; |
---|
[658f6de0] | 47 | long double _Complex ldc = ato( "123.45678901234567890123456789-123.45678901234567890123456789i" ); |
---|
[90c3b1c] | 48 | sout | ldc | "123.45678901234567890123456789-123.45678901234567890123456789i" | endl; |
---|
[658f6de0] | 49 | long double _Complex ldc2 = ato( "123.45678901234-123.4567890i" ); |
---|
[90c3b1c] | 50 | sout | ldc2 | "123.45678901234-123.4567890i" | endl; |
---|
[658f6de0] | 51 | } // main |
---|
| 52 | |
---|
| 53 | // Local Variables: // |
---|
| 54 | // tab-width: 4 // |
---|
| 55 | // compile-command: "cfa ato.c" // |
---|
| 56 | // End: // |
---|