Talk:Variable-length integer

Does this sentence mean that no one considered this encoding of integers (in a verifiable way) before the standard MIDI file format was defined in the early 198

Talk:Variable-length integer

Defined for the standard MIDI file format?

It was defined for use in the standard MIDI file format[1] to save additional space for a resource constrained system, and ....

Does this sentence mean that no one considered this encoding of integers (in a verifiable way) before the standard MIDI file format was defined in the early 1980s? If so, I am very surprised. --fcp2007 (talk) 21:06, 13 July 2008 (UTC)Reply

It more likely means that the MIDI standard was the first to define the name Variable-length Quantity for this concept.
Do you know of anyone who encoded quantities in a similar way before the MIDI standard? Please tell us about them. I think this article should mention them, even if they didn't use the exact phrase "variable-length quantity" -- since I agree with the essay WP:REFERS that articles in Wikipedia are about concepts, not particular terms.
According to the byte and 8-bit article, 8-bit microprocessors were first introduced in the 1970s. So I would be surprised (but delighted) to see a wp: reliable reference to anyone encoding integers as a variable number of full bytes before the mid 1970s. --DavidCary (talk) 15:51, 8 November 2013 (UTC)Reply

Rename page?

This page should probably be titled "base-128 encoding" or similar, and more generally describe all variations on the theme. (1 or 0 as stop bit, most significant bit group first or last significant, comparison to UTF-8 etc.) —Preceding unsigned comment added by 213.136.42.60 (talk) 13:49, 18 November 2010 (UTC)Reply

I think the two pages should be merged, but that the merged article should be titled "Var-Int" because that seems to be more commonly used in the wild than "LEB128". It could also be called "Variable-length integer" with redirections from LEB128, VarInt, VLQ, etc. Also see my comment about other names. That's my two cents. Andyjrobb (talk) 01:36, 20 June 2019 (UTC)Reply

Encoding length with VLQ

Another option is to encode the length n with VLQ and then interpret the following n bytes as a number.

Space usage:

  • VLQ: bytes
  • VLQ-length: bytes
  • VLQ-length-length: bytes
  • VLQ-length-length-length: bytes

Solomon Ucko (talk) 21:59, 4 February 2019 (UTC)Reply

Other Names for this idea

There are countless examples of this format throughout various projects, which should be added to the main article, and related articles linking back somehow:

There is currently a template-tag to move LEB128 to this page, but I think this page should be moved to LEB128. Andyjrobb (talk) 22:35, 19 June 2019 (UTC)Reply

Typo in "Two's complement section?

LEB128 uses two's complement to represent signed numbers. In this scheme of representation, n bits encodes a range from -2n to 2n-1. I guess it should be -2n - 1 to 2n - 1-1. 178.64.56.11 (talk) 01:20, 24 September 2021 (UTC)Reply

Errors within examples

I think that the table (Variable-length quantity#Examples) needs a review. There appear to be many errors in it (such as 7 digit bytes in the row for 134217728, and a "4" in the varint binary representation of 8192).

I've written a script from first principles to generate what I believe to be the correct values, please see the output below.

1 Integer (decimal)2 Integer (hexadecimal)3 Integer (binary)4 Variable-length quantity (hexadecimal)5 Variable-length quantity (binary)
0
0x00000000
00000000
0x00
00000000
127
0x0000007F
01111111
0x7F
01111111
128
0x00000080
10000000
0x81 0x00
10000001 00000000
8192
0x00002000
00100000 00000000
0xC0 0x00
11000000 00000000
16383
0x00003FFF
00111111 11111111
0xFF 0x7F
11111111 01111111
16384
0x00004000
01000000 00000000
0x81 0x80 0x00
10000001 10000000 00000000
2097151
0x001FFFFF
00011111 11111111 11111111
0xFF 0xFF 0x7F
11111111 11111111 01111111
2097152
0x00200000
00100000 00000000 00000000
0x81 0x80 0x80 0x00
10000001 10000000 10000000 00000000
134217728
0x08000000
00001000 00000000 00000000 00000000
0xC0 0x80 0x80 0x00
11000000 10000000 10000000 00000000
268435455
0x0FFFFFFF
00001111 11111111 11111111 11111111
0xFF 0xFF 0xFF 0x7F
11111111 11111111 11111111 01111111

JSFiddle with the source that generated it: https://jsfiddle.net/w6jL5qy3/

Additionally, I don't see the value in including the two Hexadecimal columns - its just confusing and detracts from the example. -Chieftain Alex 20:15, 18 April 2023 (UTC)Reply

Requested move 21 July 2026

The following is a closed discussion of a requested move. Please do not modify it. Subsequent comments should be made in a new section on the talk page. Editors desiring to contest the closing decision should consider a move review after discussing it on the closer's talk page. No further edits should be made to this discussion.

The result of the move request was: moved. Moved as an uncontested request with minimal participation. If there is any objection within a reasonable time frame, please ask me to reopen the discussion; if I am not available, please ask at the technical requests page. (closed by non-admin page mover) Jeffrey34555 (talk) 05:50, 2 August 2026 (UTC)Reply


Variable-length quantityVariable-length integer – This term is practically only used in the MIDI standard, with most other uses I can find (even quite a few on Google Scholar) just being citations to this Wikipedia page. This page was originally written as being only about the MIDI standard.

The term "variable-length integer" (alternatively "varint") is far more common, including on Google Scholar, is used by far more projects, and is more descriptive. Marboxil (talk) 13:45, 21 July 2026 (UTC) — Relisting. 1isall (talk | contribs) 14:44, 28 July 2026 (UTC)Reply

The discussion above is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.

Article scope

Replying to User:BarrelProof, thank you for the intro improvement, yes I agree it should only be about encodings using a series of bytes, what I meant was that the article contained a somewhat inconsistent mix of MIDI-specific content and content about other varint encodings and that the article might be in need of a rewrite to cover them generically.

They do most seem to be base-128, but there are some like the QUIC standard which defines a "variable-length integer" encoding [1] that is not (encodes the length in the first two bits).

Above it was suggested that LEB128 might be merged into this article, which seems sensible to me. Marboxil (talk) 16:44, 2 August 2026 (UTC)Reply

I wasn't aware of the QUIC scheme that you describe. As far as I know, it is not currently discussed in the article. —⁠ ⁠BarrelProof (talk) 16:54, 2 August 2026 (UTC)Reply

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.