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 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/hadronic/models/lend/src/nf_stringToDoubles.cc (Version 11.3.0) and /processes/hadronic/models/lend/src/nf_stringToDoubles.cc (Version 7.0.p1)


  1 /*                                                  1 
  2 # <<BEGIN-copyright>>                             
  3 # <<END-copyright>>                               
  4 */                                                
  5                                                   
  6 #include <stdlib.h>                               
  7 #include <float.h>                                
  8 #include <cmath>                                  
  9                                                   
 10 #include "nf_utilities.h"                         
 11                                                   
 12 #if defined __cplusplus                           
 13 namespace GIDI {                                  
 14 using namespace GIDI;                             
 15 #endif                                            
 16                                                   
 17 #define numberOfStaticDoubles ( 100 * 1000 )      
 18                                                   
 19 static nfu_status nfu_stringToListOfDoubles2(     
 20 /*                                                
 21 ==============================================    
 22 */                                                
 23 nfu_status nfu_stringToListOfDoubles( char con    
 24                                                   
 25     *numberConverted = 0;                         
 26     *doublePtr = NULL;                            
 27     return( nfu_stringToListOfDoubles2( str, n    
 28 }                                                 
 29 /*                                                
 30 ==============================================    
 31 */                                                
 32 static nfu_status nfu_stringToListOfDoubles2(     
 33                                                   
 34     int64_t i1, i2, numberConverted_initial =     
 35     double staticDoubles[numberOfStaticDoubles    
 36     nfu_status status = nfu_Okay;                 
 37                                                   
 38     for( i1 = 0; i1 < numberOfStaticDoubles; i    
 39         staticDoubles[i1] = strtod( str, endCh    
 40         if( str == (char const *) *endCharacte    
 41             if( *numberConverted > 0 ) {          
 42                 if( ( *doublePtr = (double *)     
 43             }                                     
 44             break;                                
 45         }                                         
 46         str = (char const *) *endCharacter;       
 47     }                                             
 48                                                   
 49     if( ( status == nfu_Okay ) && ( *doublePtr    
 50     if( *doublePtr != NULL ) {                    
 51         double *doublePtr2 = &((*doublePtr)[nu    
 52                                                   
 53         for( i2 = 0; i2 < i1; i2++, doublePtr2    
 54     }                                             
 55     return( status );                             
 56 }                                                 
 57 /*                                                
 58 ==============================================    
 59 */                                                
 60 char *nf_floatToShortestString( double value,     
 61                                                   
 62     int n1, ne, nf, digitsRightOfPeriod_f, exp    
 63     char Str_e[512], Str_f[512], *Str_r = Str_    
 64     const char *sign = "";                        
 65                                                   
 66     if( flags & nf_floatToShortestString_inclu    
 67                                                   
 68     if( !std::isfinite( value ) ) {               
 69         snprintf( Fmt, sizeof Fmt, "%%%sf", si    
 70         snprintf( Str_e, sizeof Str_e, Fmt, va    
 71         return( strdup( Str_e ) );                
 72     }                                             
 73                                                   
 74     significantDigits--;                          
 75     if( significantDigits < 0 ) significantDig    
 76     if( significantDigits > 24 ) significantDi    
 77                                                   
 78     snprintf( Fmt, sizeof Fmt, "%%%s.%de", sig    
 79     snprintf( Str_e, sizeof Str_e, Fmt, value     
 80                                                   
 81     e1 = strchr( Str_e, 'e' );                    
 82     if( significantDigits == 0 ) {                
 83         if( *(e1 - 1) != '.' ) {                  
 84             char *e3;                             
 85                                                   
 86             e2 = strchr( e1, 0 );                 
 87             e3 = e2 + 1;                          
 88             for( ; e2 != e1; e2--, e3-- ) *e3     
 89             *(e1++) = '.';                        
 90         }                                         
 91     }                                             
 92     *e1 = 0;                                      
 93     n1 = (int) strlen( Str_e ) - 1;               
 94     if( flags & nf_floatToShortestString_trimZ    
 95     ne = flags & nf_floatToShortestString_keep    
 96     if( !( flags & nf_floatToShortestString_ke    
 97     n1++;                                         
 98     Str_e[n1] = 0;                                
 99                                                   
100     e1++;                                         
101     exponent = (int) strtol( e1, &e2, 10 );       
102     if( exponent != 0 ) {               /* If     
103         for( e1 = Str_e; *e1 != 0; e1++ ) ;       
104         snprintf( e1, sizeof Str_e, "e%d", exp    
105                                                   
106         digitsRightOfPeriod_f = significantDig    
107         if( ( digitsRightOfPeriod_f > 25 ) ||     
108         if( digitsRightOfPeriod_f < 0 ) digits    
109                                                   
110         snprintf( Fmt, sizeof Fmt, "%%%s.%df",    
111         snprintf( Str_f, sizeof Str_f, Fmt, va    
112                                                   
113         ne = (int) strlen( Str_e );               
114         nf = (int) strlen( Str_f );               
115         if( strchr( Str_f, '.' ) != NULL ) {      
116             if( flags & nf_floatToShortestStri    
117             if( Str_f[nf-1] == '.' ) {            
118                 if( !( flags & nf_floatToShort    
119             } }                                   
120         else {      /* Maybe we want a '.' els    
121             if( flags & nf_floatToShortestStri    
122                 Str_f[nf] = '.';                  
123                 nf++;                             
124             }                                     
125         }                                         
126         Str_f[nf] = 0;                            
127                                                   
128         if( ( nf + favorEFormBy ) < ne ) Str_r    
129     }                                             
130     return( strdup( Str_r ) );                    
131 }                                                 
132                                                   
133 #if defined __cplusplus                           
134 }                                                 
135 #endif                                            
136