andrisp Posted March 14, 2006 Report Share Posted March 14, 2006 Pamēģiniet: alert(0.1004 * 100); Vajadzētu būt 10.04, bet izdod 10.0400000000000001; Kā tas var būt ? Link to comment Share on other sites More sharing options...
Delfins Posted March 14, 2006 Report Share Posted March 14, 2006 zināms fakts... pasearcho netu Link to comment Share on other sites More sharing options...
andrisp Posted March 14, 2006 Author Report Share Posted March 14, 2006 nezinu pēc kādiem atslēgvārdiem, lai meklēju Link to comment Share on other sites More sharing options...
Grey_Wolf Posted March 14, 2006 Report Share Posted March 14, 2006 JavaScriptam vispaar pashvaki ar matimaatiku :( Link to comment Share on other sites More sharing options...
bubu Posted March 14, 2006 Report Share Posted March 14, 2006 Jopcig, tā taču nav Javascript vaina Grey_Wolf! Tā ir normāla float skaiļu fīča PC datoros (jebkurā valodā): Šī lapa ir must read! ja grib saprast visu par floatiem - What Every Computer Scientist Should Know About Floating-Point Arithmetic Te vēl kautkas: http://owen.sj.ca.us/rkowen/howto/fltpt/ keywordi gūglei ir float precision representation. Link to comment Share on other sites More sharing options...
Grey_Wolf Posted March 14, 2006 Report Share Posted March 14, 2006 bubu--> piekriitu tik Citas valodas sho kljuudu speej pielabot/piekorijigeet... ;) un ja ir daudz shaadu apreekjinu tad gala rez. kljuda neparaadaas vai paraadaas Ljoti reti... JS izceljas ar to ka bliezj aaraa taa kaa ir... Link to comment Share on other sites More sharing options...
andrisp Posted March 14, 2006 Author Report Share Posted March 14, 2006 Ok, sapratu, bet kāds varētu būt risinājums šai lietai ? Matemātika nav mana stiprākā puse, tāpēc infu no tiem saitiem man ir grūti sagremot. Link to comment Share on other sites More sharing options...
Grey_Wolf Posted March 14, 2006 Report Share Posted March 14, 2006 andrisp--> taa kljuuda izpauzjas tikai stipri taalu aiz komata ;) (peedeejaa bitaa...) izmanto tikai tik ziimes aiz komata cik ir nepiecieshams un viss buus OK... Nu diezvai tu ko aprjekinaasi ar taadu precizitaati 15 ziimes aiz komata (kljuda izpauzjas 16).. Link to comment Share on other sites More sharing options...
Delfins Posted March 14, 2006 Report Share Posted March 14, 2006 Nu JS gadījumā pie float-display pamatā izdara Math.round... Link to comment Share on other sites More sharing options...
Recommended Posts