Re_Boot Posted April 25, 2008 Report Posted April 25, 2008 Em, es zinu ka shis maybe ir dubsh jautajums, bet man to vajag zinat: Kura no Datatype iek6 MySQL ir decimaldaljai, nu piemeram lai es field kura man vajag varu ierakstit 5.101, nu piem Datu tips INT, Boolean, text, decimal utt 1. Decimal man neder, vinjs kad es ielieku piem 5.0 parveido uz 5 2. TEXT man ari neder, tas parak daudz vietas aiznjem. Ir kadi varianti?
andrisp Posted April 25, 2008 Report Posted April 25, 2008 Priekš naudām noteikti izmanto to pašu DECIMAL. Piemēram, DECIMAL(10,2). Ievadot 5, tas izskatīšies šādi: 5.00 Ja tās nav naudas, tad vari mēģināt izmanto FLOAT. Bet nullītes tāpat neredzēsi. Un floati arī nav diezko precīzi, ja sāk ar tiem veikt aritmētiskas darbības.
Re_Boot Posted April 25, 2008 Author Report Posted April 25, 2008 (edited) Ah, man nedarbojas Decimal! :( Es lieku vai . vai , tapat parliek apakal uz 5 Edited April 25, 2008 by Re_Boot
andrisp Posted April 25, 2008 Report Posted April 25, 2008 Skaidri zini, ka tabulas kolonai tipu pielaboji ?
Re_Boot Posted April 25, 2008 Author Report Posted April 25, 2008 (edited) JAA! :( Field name: money, datatype: decimal, lenght: 65,0, default 100 Edited April 25, 2008 by Re_Boot
andrisp Posted April 25, 2008 Report Posted April 25, 2008 vot, man liekas, ka nepareizi būs pielabojis. Tur, kur length, aiz komata vajag cipariņus.
Re_Boot Posted April 25, 2008 Author Report Posted April 25, 2008 (edited) AA, liels paldies! :) Viss iet! :) Edited April 25, 2008 by Re_Boot
Re_Boot Posted April 25, 2008 Author Report Posted April 25, 2008 andrisp, bet man velviens jautajums! Ka lai izmantojot ROUND() vai kadu citu komandu vinjs noapaljo skaitli kka shadi 5.00 vai 5.21 nevis ja piemeram ir 5.215643, tad lai vinjs kka 5.21 parada tikai desmitdaljas un simtdaljas.
bubu Posted April 25, 2008 Report Posted April 25, 2008 RTFM negribās? http://dev.mysql.com/doc/refman/5.1/en/mat...#function_round ROUND(X), ROUND(X,D) Rounds the argument X to D decimal places.
Re_Boot Posted April 25, 2008 Author Report Posted April 25, 2008 Ka lai uztaisa taa ka no shadas decimaldaljas 5.212153426 vinjs noapaljo uz shadu 5.21. Ar to es domaju PHP Funkciju, kas kautko tadu dara.
andrisp Posted April 25, 2008 Report Posted April 25, 2008 http://lv2.php.net/round Un, starpcitu, DECIMAL(x,2) pats noapaļos, ja vajadzēs.
Kristabs Posted April 26, 2008 Report Posted April 26, 2008 Laikam šis komentārs pa tēmu - http://lv2.php.net/manual/en/function.floor.php#81489
Recommended Posts