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 -gt $y ]; then
            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)
2026-05-11 2026-05-10 2026-05-09 2026-05-08 2026-05-04 2026-04-28 2026-04-21 2026-03-01 2026-01-21 2026-01-06 2025-12-30 2025-11-22 2025-11-13 2025-11-07 2025-10-30 2025-10-20 2025-09-05 2025-08-29 2025-05-31 2025-05-21 2025-05-18 2025-05-06 2025-05-04 2025-05-03 2025-04-23 2025-04-16 2025-04-01 2025-03-24 2025-02-18 2025-01-13 2025-01-11 2024-12-07 2024-11-30 2024-11-12 2024-11-08 2024-10-21 2024-10-18 2024-10-16 2024-09-22

Front page   Edit Freeze Diff History Attach Copy Rename Reload   New Page list Search Recent changes   Help   RSS of recent changes
Last-modified: 2010-05-21 (Fri) 22:09:04