Skip to content

Casting infinity to integer makes value 0 #6737

Closed as duplicate
Closed as duplicate
@cometkim

Description

@cometkim
let t1 = infinity->Belt.Float.toInt
let t2 = infinity->Float.toInt

generates

import * as PervasivesU from "./stdlib/pervasivesU.js";

var t1 = PervasivesU.infinity | 0;

var t2 = PervasivesU.infinity | 0;

both are 0. so we don't actually have a way to compare int value with the infinity without %raw. because infinity in pervasive is float

Infinity is often used in arithmetic operations as well as a value indicating "no limit" (e.g. pagination)

#6038 also mentioned

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleOld issues that went stale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions