Skip to content

printf("%d", -2147483648) shows an extra "-" #3148

@tsahara

Description

@tsahara

(confirmed on OpenBSD/amd64 and MacOS)

% bin/mruby -e 'printf("%d\n", -2147483648)'
--2147483648

It works as expected for -2147483647 and -2147483649:

% bin/mruby -e 'printf("%d\n", -2147483647)'
-2147483647

% bin/mruby -e 'printf("%d\n", -2147483649)'
trace:
    [0] /Users/tsahara/src/mruby/mrbgems/mruby-print/mrblib/print.rb:60:in Kernel#printf
    [1] -e:1
/Users/tsahara/src/mruby/mrbgems/mruby-print/mrblib/print.rb:60: number (-2147483649) too big for integer (ArgumentError)

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