Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

add floating point comparison functions #2

@icasimpan

Description

@icasimpan
## https://stackoverflow.com/questions/8654051/how-can-i-compare-two-floating-point-numbers-in-bash
##
num1_gt_num2() {
    local num1=$1
    local num2=$2

    local retval=$FALSE
    if (( $(echo "$num1 > $num2" | bc -l) )); then
        retval=$TRUE
    fi

    echo $retval
}

num1_lt_num2() {
    local num1=$1
    local num2=$2

    local retval=$FALSE
    [[ "$(num1_gt_num2 $num1 $num2)" = "0" ]] && retval=$TRUE

    echo $retval
}```


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions