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