#include <fixed.h>
Public Types | |
| enum | { ALIGN = 1, COMMAS = 2, DECIMAL = 4 } |
Public Member Functions | |
| void | equalize_precision (Fixed &) |
| void | setprecision (int) |
| Fixed (int x, int p) | |
| Fixed (QString a) | |
| Fixed (const char *a) | |
| Fixed () | |
| Fixed | operator[] (int) const |
| Fixed | operator= (Fixed) |
| Fixed | operator= (int) |
| QString | toQString (QChar separadorDecimal= ',') |
Data Fields | |
| Fixed_numerator | value |
| int | precision |
Private Member Functions | |
| void | fromFixed (const char *) |
Friends | |
| Fixed | operator+ (Fixed, Fixed) |
| Fixed | operator- (Fixed, Fixed) |
| Fixed | operator * (Fixed, Fixed) |
| Fixed | operator/ (Fixed, Fixed) |
| Fixed | operator- (Fixed) |
| bool | operator== (Fixed, Fixed) |
| bool | operator< (Fixed, Fixed) |
| Fixed | operator- (int, Fixed) |
| Fixed | operator/ (int, Fixed) |
| bool | operator== (int, Fixed) |
| bool | operator< (int, Fixed) |
| Fixed | operator+ (Fixed, int) |
| Fixed | operator- (Fixed, int) |
| Fixed | operator * (Fixed, int) |
| Fixed | operator/ (Fixed, int) |
| bool | operator== (Fixed, int) |
| bool | operator< (Fixed, int) |
Definition at line 26 of file fixed.h.
| anonymous enum |
| Fixed::Fixed | ( | int | x, | |
| int | p | |||
| ) |
| Fixed::Fixed | ( | QString | a | ) |
| Fixed::Fixed | ( | const char * | a | ) |
| Fixed::Fixed | ( | ) |
Definition at line 56 of file fixed.cpp.
References _depura(), precision, and value.
Referenced by FichaBf::calculaypintatotales(), FichaBf::generaRML(), FichaBf::trataLineasDescuento(), FichaBf::trataLineasDetalle(), and FichaBf::trataTotales().
00056 { 00057 _depura("Fixed::Fixed", 0); 00058 value = 0; 00059 precision = 1; 00060 _depura("END Fixed::Fixed", 0); 00061 00062 }
| void Fixed::fromFixed | ( | const char * | s | ) | [private] |
| s |
Definition at line 224 of file fixed.cpp.
References _depura(), MAX_FIXED_PRECISION, precision, and value.
Referenced by Fixed().
00224 { 00225 _depura("Fixed::fromFixed", 0); 00226 value = 0; 00227 precision = 0; 00228 int c; 00229 while ((c = *s++) == ' ' || c == '\t') 00230 ; 00231 bool negative; 00232 if (c == '-') { 00233 negative = true; 00234 c = *s++; 00235 } else { 00236 negative = false; 00237 } // end if 00238 bool decimal = false; 00239 while (precision < MAX_FIXED_PRECISION) { 00240 if ('0' <= c && c <= '9') { 00241 value = value * 10 + (c - '0'); 00242 if (decimal) 00243 precision++; 00244 } else if (c == '.' || c ==',') { 00245 if (decimal) 00246 break; 00247 decimal = true; 00248 } else if (c != ',') 00249 break; 00250 c = *s++; 00251 } // end while 00252 if (negative) 00253 value = - value; 00254 if (value == 0) 00255 precision = 1; 00256 _depura("END Fixed::fromFixed", 0); 00257 }
| void Fixed::equalize_precision | ( | Fixed & | x | ) |
| x |
Definition at line 183 of file fixed.cpp.
References _depura(), precision, and value.
Referenced by operator+(), operator-(), operator<(), and operator==().
00183 { 00184 _depura("Fixed::equalize_precision", 0); 00185 while (precision < x.precision) { 00186 value *= 10; 00187 precision ++; 00188 } // end while 00189 while (x.precision < precision) { 00190 x.value *= 10 ; 00191 x.precision ++; 00192 } // end while 00193 _depura("END Fixed::equalize_precision", 0); 00194 }
| void Fixed::setprecision | ( | int | prec | ) |
| prec |
Definition at line 201 of file fixed.cpp.
References _depura(), precision, and value.
Referenced by toQString().
00201 { 00202 _depura("Fixed::setprecision", 0); 00203 while (precision < prec) { 00204 value *= 10; 00205 precision ++; 00206 } // end while 00207 while (prec < precision) { 00208 Fixed_numerator aux; 00209 aux = value; 00210 value = (Fixed_numerator) (value / 10); 00211 if ((aux % 10) >=5) { 00212 value++; 00213 } // end if 00214 precision--; 00215 } // end while 00216 _depura("END Fixed::setprecision", 0); 00217 }
| Fixed Fixed::operator[] | ( | int | ) | const |
| Fixed Fixed::operator= | ( | int | ) |
| QString Fixed::toQString | ( | QChar | separadorDecimal = ',' |
) |
| separadorDecimal |
prevent buffer overflow if result is still negative.
10/07/2007 Se cambio para poder poner otro caracter como separador decimal.
Definition at line 115 of file fixed.cpp.
References _depura(), ALIGN, COMMAS, DECIMAL, integer(), MAX_FIXED_LENGTH, MAX_FIXED_PRECISION, precision, setprecision(), and value.
Referenced by libromayorprint::accept(), CAnualesPrintView::agregaValores(), Asiento1View::asiento_regularizacion(), pluginCAnualesODS::balanceSituacionODS(), Asiento1View::calculaypintatotales(), Q19QToolButton::click(), EFQToolButton::escribe_descuento_factura(), EFQToolButton::escribe_linea_factura(), FichaBf::generaRML(), Arbol::hojaactual(), extractoview1::imprimeExtractoCuenta(), Ticket::imprimir(), Ticket::insertarArticulo(), EFQToolButtonImportar::obten_descuento_factura(), CAnualesPrintView::on_mui_aceptar_clicked(), RegistroIvaView::on_mui_generarPrevisiones_clicked(), RegistroIvaView::pintabaseimp(), RegistroIvaView::pintaiva(), MTicket::pintar(), PresupuestoView::pintatotales(), PedidoProveedorView::pintatotales(), PedidoClienteView::pintatotales(), FacturaView::pintatotales(), FacturaProveedorView::pintatotales(), AlbaranProveedorView::pintatotales(), AlbaranClienteView::pintatotales(), Ticket::ponerCantidad(), Ticket::ponerPrecio(), PagosList::presentar(), CobrosList::presentar(), extractoview1::presentar(), AsientosView::presentar(), BalanceView::presentarSyS(), CAnualesPrintView::procesaFormula(), cobropagoview::s_recalculaSaldo(), Ticket_pintar(), FichaBf::trataLineasDescuento(), FichaBf::trataLineasDetalle(), and FichaBf::trataTotales().
00115 { 00116 _depura("Fixed::toQString", 0); 00117 setprecision(2); 00118 int options = COMMAS; 00119 Fixed_numerator x = value; 00120 bool negative; 00121 if (x < 0) { 00122 x = -x; 00124 if (x < 0) 00125 x = x - 1; 00126 negative = true; 00127 } else 00128 negative = false; 00129 Fixed_numerator n = 0; 00130 Fixed_numerator units = 0; 00131 unsigned char buffer[MAX_FIXED_LENGTH + MAX_FIXED_PRECISION]; 00132 for (unsigned int i = 0; i <= sizeof(buffer); i++) 00133 buffer[i] = 0; 00134 do { 00135 if (n == precision) { 00136 if (n > 0 || options & DECIMAL) 00139 //buffer[sizeof(buffer) - ++n] = ','; 00140 00141 buffer[sizeof(buffer) - ++n] = separadorDecimal.toAscii(); 00142 00143 units = n; 00144 } 00145 Fixed_numerator y; 00146 y = (Fixed_numerator) x / 10; 00147 buffer[sizeof(buffer) - ++n] = integer(x - y * 10) + '0'; 00148 x = y; 00149 } while (n <= precision || x != 0); 00150 if (negative) 00151 buffer[sizeof(buffer) - ++n] = '-'; 00152 if (options & ALIGN) { 00153 while (n - units < MAX_FIXED_LENGTH - 2) 00154 buffer[sizeof(buffer) - ++n] = ' '; 00155 } 00156 QString a((const char *) buffer + sizeof(buffer) - n); 00157 _depura("END Fixed::toQString", 0); 00158 return a; 00159 }
Definition at line 65 of file fixed.cpp.
00065 { 00066 x.equalize_precision(y); 00067 x.value = x.value + y.value; 00068 return x; 00069 }
Definition at line 302 of file fixed.cpp.
00302 { 00303 x.equalize_precision(y); 00304 x.value = x.value - y.value; 00305 return x; 00306 }
Definition at line 162 of file fixed.cpp.
00162 { 00163 x.equalize_precision(y); 00164 return x.value == y.value; 00165 }
Definition at line 260 of file fixed.cpp.
00260 { 00261 x.equalize_precision(y); 00262 return x.value < y.value; 00263 }
| bool operator== | ( | int | x, | |
| Fixed | y | |||
| ) | [friend] |
| bool operator< | ( | int | x, | |
| Fixed | y | |||
| ) | [friend] |
| bool operator== | ( | Fixed | x, | |
| int | y | |||
| ) | [friend] |
| bool operator< | ( | Fixed | x, | |
| int | y | |||
| ) | [friend] |
Definition at line 32 of file fixed.h.
Referenced by FichaBf::calculaypintatotales(), equalize_precision(), Fixed(), fromFixed(), FichaBf::generaRML(), Ticket::imprimir(), PedidoProveedorView::imprimir(), FacturaProveedorView::imprimirFacturaProveedor(), operator *(), operator+(), operator-(), operator/(), operator<(), operator=(), operator==(), MTicket::pintar(), setprecision(), Ticket_pintar(), toQString(), and FichaBf::trataTotales().
| int Fixed::precision |
Definition at line 33 of file fixed.h.
Referenced by equalize_precision(), Fixed(), fromFixed(), operator *(), operator/(), operator=(), setprecision(), and toQString().
1.5.1