[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] C og regex



Christian Nielsen <sslug@sslug> writes:

> Er programmerer normalt i PERL, så C er noget fremmed.
> Desværre regner PERL forkert, hvis man lægger mange små tal sammen.

Det er næppe en fejl i Perl (ikke PERL) men skyldes sikkert at du
bruger "floating point" tal. Perl's tal er det samme som "double" i C,
så at skifte til C vil næppe hjælpe (med mindre du fx bruger "long
double", men den er ikke meget mere præcis).

Læs fx http://docs.sun.com/source/806-3568/ncg_goldberg.html for lidt
om hvordan "floating point" fungerer og hvilke begrænsninger det har.

Hvis du vil lave beregninger med mere præcision kan du bruge fx GNU
MP biblioteket. Den har endda rationelle tal, så du kan lave
beregninger uden at tabe præcision overhovedet (men det bliver langsommere).

Der er ingen grund til at skifte væk fra Perl endnu; der findes
bindinger for GMP for Perl. De fleste af dine beregninger kan så
holdes i GMP's hurtigere C kode.

-- 
===============================================================
<sslug@sslug>                           Herlev, Denmark     
<URL:http://www.andreasen.org/>                             <*>   
===============================================================



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:43 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *