int main( void ) { if( test_function( 0xffffffff ) ) fail( __LINE__ ); if( rshift_i( 256 ) != 8 ) fail( __LINE__ ); if( rshift_i( -256 ) != -8 ) fail( __LINE__ ); if( lshift_i( 3 ) != 24 ) fail( __LINE__ ); if( lshift_i( -3 ) != -24 ) fail( __LINE__ ); if( div_i( -1 ) != 0 ) fail( __LINE__ ); if( div_i( 100000 ) != 1 ) fail( __LINE__ ); if( mod_i( -1 ) != -1 ) fail( __LINE__ ); if( mod_i( -100000 ) != -13600 ) fail( __LINE__ ); if( div_f( -1 ) != -0.25 ) fail( __LINE__ ); if( div_f( 10 ) != 2.5 ) fail( __LINE__ ); _PASS; }
/** * @brief Tlacitko pro rovna se - provede se vypocet operaci o dvou operandech */ void MainWindow::rovno() { druhyNum = value.toDouble(); switch (proces) { /* pouze cislo */ case -1: total = QString::number(druhyNum); lcd -> display(total); break; case 0: total = QString::number(druhyNum); lcd -> display(total); break; /* scitani */ case 1: total = QString::number(add_f( prvniNum, druhyNum), 'g'); lcd -> display(total); break; /* odcitani */ case 2: total = QString::number(sub_f( prvniNum, druhyNum), 'g'); lcd -> display(total); break; /* nasobeni */ case 3: total = QString::number(mul_f( prvniNum, druhyNum), 'g'); lcd -> display(total); break; /* deleni */ case 4: if(druhyNum != 0) { total = QString::number(div_f( prvniNum, druhyNum), 'g'); lcd -> display(total); } else { total = "0"; lcd -> display("Err04"); } break; /* mocnina */ case 5: if((druhyNum - int(druhyNum)) != 0) { total = "0"; lcd -> display("Err05"); } else { druhyNum_int = int(druhyNum); total = QString::number(pow_f( prvniNum, druhyNum_int), 'g'); lcd -> display(total); } break; /* default = error */ default: lcd -> display("Err42"); } prvniNum = total.toDouble(); if (total == "0") total = ""; value = total; proces = -1; total = ""; }