#This work is licensed under the
#Creative Commons Attribution-Share Alike 3.0 United States License.
#To view a copy of this license, visit
#http://creativecommons.org/licenses/by-sa/3.0/us/ or send a letter to
#Creative Commons,
#171 Second Street, Suite 300,
#San Francisco, California, 94105, USA.

INPUT "the Shorten file stream",bit_count;
OUTPUT "a signed value";
VAR bit_count "bit count";
VAR unsigned_ "unsigned";
FUNC read_unsigned "read unsigned" "shorten:read_unsigned";
unsigned_ <- read_unsigned(bit_count + 1);
if unsigned_ % 2 == 0 {
    return unsigned_ / 2;
} else {
    return -floor(unsigned_ / 2) - 1;
}
