| OLD | NEW |
| 1 /* | 1 /* |
| 2 ** 2013-06-10 | 2 ** 2013-06-10 |
| 3 ** | 3 ** |
| 4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
| 5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
| 6 ** | 6 ** |
| 7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
| 8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
| 9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
| 10 ** | 10 ** |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 a[n] = a[n-1]; | 140 a[n] = a[n-1]; |
| 141 n++; | 141 n++; |
| 142 } | 142 } |
| 143 }else if( strcmp(z,"log")==0 ){ | 143 }else if( strcmp(z,"log")==0 ){ |
| 144 if( n>0 ) a[n-1] = logEstFromInteger(a[n-1]) - 33; | 144 if( n>0 ) a[n-1] = logEstFromInteger(a[n-1]) - 33; |
| 145 }else if( strcmp(z,"nlogn")==0 ){ | 145 }else if( strcmp(z,"nlogn")==0 ){ |
| 146 if( n>0 ) a[n-1] += logEstFromInteger(a[n-1]) - 33; | 146 if( n>0 ) a[n-1] += logEstFromInteger(a[n-1]) - 33; |
| 147 }else if( strcmp(z,"inv")==0 ){ | 147 }else if( strcmp(z,"inv")==0 ){ |
| 148 if( n>0 ) a[n-1] = -a[n-1]; | 148 if( n>0 ) a[n-1] = -a[n-1]; |
| 149 }else if( z[0]=='^' ){ | 149 }else if( z[0]=='^' ){ |
| 150 a[n++] = atoi(z+1); | 150 a[n++] = (LogEst)atoi(z+1); |
| 151 }else if( isInteger(z) ){ | 151 }else if( isInteger(z) ){ |
| 152 a[n++] = logEstFromInteger(atoi(z)); | 152 a[n++] = logEstFromInteger(atoi(z)); |
| 153 }else if( isFloat(z) && z[0]!='-' ){ | 153 }else if( isFloat(z) && z[0]!='-' ){ |
| 154 a[n++] = logEstFromDouble(atof(z)); | 154 a[n++] = logEstFromDouble(atof(z)); |
| 155 }else{ | 155 }else{ |
| 156 showHelp(argv[0]); | 156 showHelp(argv[0]); |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 for(i=n-1; i>=0; i--){ | 159 for(i=n-1; i>=0; i--){ |
| 160 if( a[i]<-40 ){ | 160 if( a[i]<-40 ){ |
| 161 printf("%5d (%f)\n", a[i], 1.0/(double)logEstToInt(-a[i])); | 161 printf("%5d (%f)\n", a[i], 1.0/(double)logEstToInt(-a[i])); |
| 162 }else if( a[i]<10 ){ | 162 }else if( a[i]<10 ){ |
| 163 printf("%5d (%f)\n", a[i], logEstToInt(a[i]+100)/1024.0); | 163 printf("%5d (%f)\n", a[i], logEstToInt(a[i]+100)/1024.0); |
| 164 }else{ | 164 }else{ |
| 165 sqlite3_uint64 x = logEstToInt(a[i]+100)*100/1024; | 165 sqlite3_uint64 x = logEstToInt(a[i]+100)*100/1024; |
| 166 printf("%5d (%lld.%02lld)\n", a[i], x/100, x%100); | 166 printf("%5d (%lld.%02lld)\n", a[i], x/100, x%100); |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 return 0; | 169 return 0; |
| 170 } | 170 } |
| OLD | NEW |