negative mfs size at large memory

メッセージ

more than 2^31 bytes are displayed as negative value.
Because ksh can handle integer range of -2^31 ... 2^31-1

On ksh, this is like this;

$ echo $((2147483647))     # 2^31-1
2147483647
$ echo $((2147483647+1))   # 2^31
-2147483648

Here's a concept code to check two strings representing big non-negative integer values.

#!/bin/ksh

function isgreater {
    # check presence of arguments
    #
    [ $# -lt 2 ] && return -- -1

    x=$1
    y=$2

    # Are arguments both form of positive integer?
    #
    case "$x" in
        0|[1-9]*([0-9])) :            ;; # ok, do nothing
                      *) return -- -2 ;; # ng, string is not positive integer 
    esac
    case "$y" in
        0|[1-9]*([0-9])) :            ;; # ok, do nothing
                      *) return -- -2 ;; # ng, string is not positive integer 
    esac

    # Compare it
    #
    if [ ${#x} -gt ${#y} ]; then
        return 0
    elif [ ${#x} -eq ${#y} ]; then
        if [ $x \> $y ]; then # string compare (not documented in ksh(1))
            return 0
        else
            return 1
        fi
    else
        return 1
    fi
}

isgreater $1 $2
case $? in
    0) echo $1 is greater than $2. ;;
    1) echo $1 is NOT greater than $2. ;;
    *) echo argument format error ;;
esac

Note


recent(50)
2023-01-24 2023-01-22 2022-12-23 2022-12-13 2022-11-17 2022-11-15 2022-11-14 2022-11-13 2022-11-12 2022-11-08 2022-11-05 2022-10-18 2022-09-28 2022-08-08 2022-08-07 2022-04-11 2022-03-10 2022-01-19 2021-12-11 2021-10-02 2021-08-28 2021-05-31 2021-05-21 2021-05-14 2021-04-16 2020-10-07 2020-07-22 2020-06-20 2020-06-14 2020-05-15 2020-02-28 2020-02-07 2019-12-11 2019-10-09 2019-05-25 2019-04-04

Front page   Edit Freeze Diff History Attach Copy Rename Reload   New Page list Search Recent changes   Help   RSS of recent changes
Last-modified: 2009-05-19 (Tue) 12:00:30