Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- . float.subr || exit
- # https://raw.githubusercontent.com/FrauBSD/FrauBSD/master/usr.sbin/bsdconfig/share/float.subr
- N=1
- EXIT=${SUCCESS:-0}
- HR="--------------------"
- VERBOSE=
- hrprint() { printf "%s #%03u %s\n" "$HR" "$N" "$HR"; }
- hr() { [ "$VERBOSE" ] && hrprint; }
- xt()
- {
- local float1="$1" float2="$3" testvalue="$5" result=
- hr
- f_float "$float1" + "$float2" result
- if [ "$result" = "$testvalue" ]; then
- [ "$VERBOSE" ] && echo "$float1 + $float2 == $result"
- else
- [ "$VERBOSE" ] || hrprint
- echo "$float1 + $float2 == $result [bad; expected $testvalue]"
- EXIT=${FAILURE:-1}
- fi
- N=$(( $N + 1 ))
- }
- : 001 ; xt 0.009 + 0.019 == 0.028
- : 002 ; xt 0.001 + 0.019 == 0.02
- : 003 ; xt 0.090 + 0.019 == 0.109
- : 004 ; xt 0.990 + 0.019 == 1.009
- : 005 ; xt 0.990 + 0.01 == 1.0
- : 006 ; xt 0.99 + 0.01 == 1.0
- : 007 ; xt 0.990 + 0.01 == 1.0
- : 008 ; xt 0.090 + 0.019 == 0.109
- : 009 ; xt 0.001 + 0.019 == 0.02
- : 010 ; xt 0.009 + 0.019 == 0.028
- : 011 ; xt 0.009 + 0.09 == 0.099
- : 012 ; xt 0.005 + 0.01 == 0.015
- : 013 ; xt 0.005 + 0.010 == 0.015
- : 014 ; xt 0.05 + 0.010 == 0.06
- : 015 ; xt 0.5 + 0.010 == 0.51
- : 016 ; xt 0.5 + 0.01 == 0.51
- : 017 ; xt 0.5 + 0.25 == 0.75
- : 018 ; xt 0.1 + 0.5 == 0.6
- : 019 ; xt 768614336404564650 + 1 == 768614336404564651
- : 020 ; xt 0.768614336404564650 + 0.300000000000000001 == 1.068614336404564651
- : 021 ; xt 58924.2049 + 123.66 == 59047.8649
- : 022 ; xt 1 + 1 == 2
- : 023 ; xt -1 + -2 == -3
- : 024 ; xt -2 + 1 == -1
- : 025 ; xt -1 + 1 == 0
- : 026 ; xt 1 + -1 == 0
- : 027 ; xt 1 + -2 == -1
- : 028 ; xt -2 + -1 == -3
- : 029 ; xt 0 + 0 == 0
- : 030 ; xt 0.0 + 1 == 1.0
- : 031 ; xt .0 + 1 == 1.0
- : 032 ; xt .0 + 0 == 0.0
- : 033 ; xt .0 + .0 == 0.0
- : 034 ; xt . + . == 0
- : 035 ; xt a + b == 0
- : 036 ; xt a + . == 0
- : 037 ; xt a + 0.0 == 0.0
- : 038 ; xt a + .0 == 0.0
- : 039 ; xt 0 + 0.00 = 0.0
- : 040 ; xt -2 + -1 == -3
- : 041 ; xt 1 + -2 == -1
- : 042 ; xt 1 + -1 == 0
- : 043 ; xt -1 + 1 == 0
- : 044 ; xt -2 + 1 == -1
- : 045 ; xt -1 + -2 == -3
- : 046 ; xt 1 + 0.0 == 1.0
- : 047 ; xt 1 + .0 == 1.0
- : 048 ; xt 0 + .0 == 0.0
- : 049 ; xt . + a == 0
- : 050 ; xt 0.0 + a == 0.0
- : 051 ; xt .0 + a == 0.0
- : 052 ; xt 0.00 + 0 = 0.0
- : 053 ; xt 0.01 + 256.000000000000000000010 == 256.01000000000000000001
- exit $EXIT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement