[vim/vim] Decrementing octal number does not preserve lenght (Issue #11889)

11 views
Skip to first unread message

Gurran

unread,
Jan 26, 2023, 7:44:34 AM1/26/23
to vim/vim, Subscribed

Steps to reproduce

In normal mode decrement (Ctrl-X) the following number
000000000
it returns
01777777777777777777777

Expected behaviour

The result should preserve the length of the number and result in
017777777

Version of Vim

9.0 1051

Environment

Ubuntu 22.04.1 LTS
Gnome Terminal
xterm-256color
ZSH

Logs and stack traces

No response


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11889@github.com>

Marvin Renich

unread,
Jan 26, 2023, 11:01:03 AM1/26/23
to vim...@googlegroups.com
* Gurran <vim-dev...@256bit.org> [230126 07:44]:
> ### Steps to reproduce
>
> In normal mode decrement (`Ctrl-X`) the following number
> `000000000`
> it returns
> `01777777777777777777777`
>
> ### Expected behaviour
>
> The result should preserve the length of the number and result in
> `017777777`

I'm not sure the current behavior is wrong. Octal numbers are treated
as unsigned, and 64-bit arithmetic is being used.

The help says "Vim preserves the number of characters in the number when
possible." Note that if you use Ctrl-A on 077 you get 0100. The result
of Ctrl-X on 0000 is (2*64)-1, which requires more digits to represent.

Bram should determine what he intended here, and what makes most sense,
but I think the current behavior makes more sense and obeys the docs.

...Marvin

Bram Moolenaar

unread,
Jan 26, 2023, 3:37:45 PM1/26/23
to vim...@googlegroups.com, Marvin Renich
Changing the resulting value is not backwards compatible. It might
cause problems (although I doubt more than a few users actually use
octal numbers these days).

There are a few alternatives to the current behavior, and I can't say
any of them is really better than the current behavior. E.g., going to
minus one or considering the change to be an error (disallow wraparound).

We could perhaps make the help a bit clearer. Any suggestions?

--
hundred-and-one symptoms of being an internet addict:
53. To find out what time it is, you send yourself an e-mail and check the
"Date:" field.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Gurran

unread,
Feb 6, 2023, 4:34:47 AM2/6/23
to vim/vim, Subscribed

I've recompiled Vim and issue still exists on version 9.0 Included patches: 1-1285


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11889/1418781206@github.com>

Marvin Renich

unread,
Feb 6, 2023, 9:45:46 AM2/6/23
to vim...@googlegroups.com, Gurran
* Gurran <vim-dev...@256bit.org> [230206 04:34]:
> I've recompiled Vim and issue still exists on version 9.0 Included patches: 1-1285

The discussion of this happened on vim...@googlegroups.com (msgs from
the github issue tracker seem to be forwarded here). You can read the
thread on googlegroups, but in summary, the current behavior is correct
and is not going to change. Bram said he may try to make the help a
little more clear (which may be why he didn't close the issue).

When I replied to your original msg, I didn't realize you may not be
subscribed to the mailing list, so I neglected to CC you; I apologize.
(I am subscribed to vim_dev, so no need to CC me in msgs sent to the
group.)

...Marvin

Bram Moolenaar

unread,
Feb 6, 2023, 3:47:27 PM2/6/23
to vim/vim, Subscribed

Comment from Marvin Renich on the vim-dev list was not included here:

I'm not sure the current behavior is wrong. Octal numbers are treated
as unsigned, and 64-bit arithmetic is being used.

The help says "Vim preserves the number of characters in the number when
possible." Note that if you use Ctrl-A on 077 you get 0100. The result
of Ctrl-X on 0000 is (2*64)-1, which requires more digits to represent.

Bram should determine what he intended here, and what makes most sense,
but I think the current behavior makes more sense and obeys the docs.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11889/1419727422@github.com>

Bram Moolenaar

unread,
Feb 6, 2023, 3:47:51 PM2/6/23
to vim/vim, Subscribed

My comment on the vim-dev list was not included here:

Changing the resulting value is not backwards compatible. It might
cause problems (although I doubt more than a few users actually use
octal numbers these days).

There are a few alternatives to the current behavior, and I can't say
any of them is really better than the current behavior. E.g., going to
minus one or considering the change to be an error (disallow wraparound).

We could perhaps make the help a bit clearer. Any suggestions?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11889/1419727946@github.com>

Gurran

unread,
Mar 21, 2023, 10:00:29 AM3/21/23
to vim/vim, Subscribed

The reason why I discovered this was because Vim parses Docker tags as octal numbers.

I don't really care about octal numbers, just thought that this behavior was weird.
The solution to my problem would be to either explicitly tell vim to do a base10 increment, or disable the "smart" guessing.

I'm not familiar with the code so I don't know where to look.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11889/1477888786@github.com>

Christian Brabandt

unread,
Mar 21, 2023, 10:10:29 AM3/21/23
to vim/vim, Subscribed

so I guess you want: :set nrformat-=octal


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11889/1477906523@github.com>

Gurran

unread,
Mar 21, 2023, 10:36:44 AM3/21/23
to vim/vim, Subscribed

so I guess you want: :set nrformat-=octal

Yes! I didn't know that nrformat existed.

Thanks for the help. Sorry to bother you.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11889/1477953927@github.com>

Gurran

unread,
Mar 21, 2023, 10:36:46 AM3/21/23
to vim/vim, Subscribed

Closed #11889 as completed.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/11889/issue_event/8806444247@github.com>

Reply all
Reply to author
Forward
0 new messages