Problems with math:sqrt module

Greg Perry Greg.Perry@REDACTED
Fri Jul 10 20:13:27 CEST 2009


I found what appears to be a problem with the multi precision math capabilities of Erlang, math:sqrt works fine for fairly large numbers but errors with a 2048 bit semiprime number, for example:

11> math:sqrt(3583144093694177840015703951812811819685389811654227013562705143239732783869692090471778208318589531694265620448681377942529266640295861138161515558643627087037345328746390159109263363877363094390).                                              5.985936930585034e97  

...works fine, but a 2048 bit number does not:
                                                                       
12> math:sqrt(358314409369417784001570395181281181968538981165422701356270514323973278386969209047177820831858953169426562044868137794252926664029586113816151555864362708703734532874639015910926336387736309439085113066643724657508768560218902742830031805141689201216753646475132835879627107400965023578409921487110512182961741061327409228793561655530765043642780534852247342070264867175687046721404689620610752507).
** exception error: bad argument in an arithmetic expression
     in function  math:sqrt/1
        called as math:sqrt(358314409369417784001570395181281181968538981165422701356270514323973278386969209047177820831858953169426562044868137794252926664029586113816151555864362708703734532874639015910926336387736309439085113066643724657508768560218902742830031805141689201216753646475132835879627107400965023578409921487110512182961741061327409228793561655530765043642780534852247342070264867175687046721404689620610752507)
13> 

any ideas?


More information about the erlang-questions mailing list