Skip to content

Unexpected NaN from sqrt() #164

Open
@hypcos

Description

@hypcos

I expected that X.sqrt() should give similar result to X.pow(0.5), but it doesn't.
Especially when the layer is 1.
Example:

> new Decimal(1e-16).pow(0.5)+''
< '1.000000000000002e-8'
> new Decimal(1e-16).sqrt()+''
< 'NaN'
> new Decimal(1e16).neg().pow(0.5)+''
< 'NaN'
> new Decimal(1e16).neg().sqrt()+''
< '99999999.99999979'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions