<p>On bitcoin wiki site I cant found this specification:</p>

<p>*The stacks hold byte vectors. When used as numbers, byte vectors are interpreted as little-endian variable-length integers with the most significant bit determining the sign of the integer. Thus 0x81 represents -1. 0x80 is another representation of zero (so called negative 0). Positive 0 is represented by a null-length vector. Byte vectors are interpreted as Booleans where False is represented by any representation of zero, and True is represented by any representation of non-zero. *</p>

<p><a href="https://en.bitcoin.it/wiki/Script" rel="nofollow">https://en.bitcoin.it/wiki/Script</a></p>

<p>But on bitcoins source code test scripts I have found this:</p>

<pre><code>["0x02 0x417a", "'Az' EQUAL", "P2SH,STRICTENC"],

["0x4b 0x417a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a",
"'Azzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz' EQUAL", "P2SH,STRICTENC", "push 75 bytes"],
</code></pre>

<p><a href="https://github.com/bitcoin/bitcoin/blob/master/src/test/data/script_valid.json#L26" rel="nofollow">https://github.com/bitcoin/bitcoin/blob/master/src/test/data/script_valid.json#L26</a></p>

<p>So, as I understand this is test for script module of bitcoin core, and this few tests put numbers into stack, then put byte string into stack and process EQUAL opcode.
 But in case if numbers should stored in stack as little endian variable int with sign bit (bitcoin wiki) number 0x417a is stored as b'zA' and not as 'Az'.</p>

<p>Number 0x417a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a </p>

<p>will be</p>

<p>zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzA</p>

<p>What type of numbers representation in stack we have to use?</p>

<ul>
<li>varint little endian with sign bit ? (bitcoin wiki)</li>
<li>big endian ?</li>
<li>4 byte big endian ? (found on bitcoin source codes class CScriptNum github.com/bitcoin/bitcoin/blob/master/src/script/script.h#L187)</li>
</ul>

<p>Where I can read exactly specification ?</p>

<p>Thank you</p>

CC BY-SA 3.0
2015-08-02T21:41:18.773Z
It's not interpreted as a number in the example you give, because you're using OP_EQUAL, not OP_NUMEQUAL. The encoding for numbers doesn't enter into it at all.
Nick ODell
CC BY-SA 3.0
2015-08-02T21:44:45.980Z
This is a really good example of how OP_EQUAL and OP_NUMEQUAL differ: https://github.com/bitcoin/bitcoin/blob/master/src/test/data/script_valid.json#L372
Nick ODell
CC BY-SA 3.0
2015-08-02T21:49:58.247Z
Thank you for quick reply, could you tell me what excatly format of integer numbers using in stack in case if using opcodes works with numbers? Is the correct specification on bitcoin wiki?
bitaps.com
CC BY-SA 3.0
2015-08-02T21:51:16.330Z
https://github.com/richardkiss/pycoin/blob/master/pycoin/intbytes.py using BIG endian unsigned format ( I think its wrong)
bitaps.com
CC BY-SA 3.0
2015-08-02T21:52:51.583Z
https://github.com/petertodd/python-bitcoinlib/blob/master/bitcoin/core/_bignum.py  using little endian varing with sign bit like on bitwiki . Is this correct?
bitaps.com
<script><specification>
Bitcoin script stack numbers format
bitaps.com
# Bitcoin script stack numbers format

(Asked by: username_0 on 2015-08-02)

On bitcoin wiki site I cant found this specification:

\*The stacks hold byte vectors. When used as numbers, byte vectors are interpreted as little-endian variable-length integers with the most significant bit determining the sign of the integer. Thus 0x81 represents -1. 0x80 is another representation of zero (so called negative 0). Positive 0 is represented by a null-length vector. Byte vectors are interpreted as Booleans where False is represented by any representation of zero, and True is represented by any representation of non-zero. \*

<https://en.bitcoin.it/wiki/Script>

But on bitcoins source code test scripts I have found this:

```
["0x02 0x417a", "'Az' EQUAL", "P2SH,STRICTENC"],

["0x4b 0x417a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a",
"'Azzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz' EQUAL", "P2SH,STRICTENC", "push 75 bytes"],

```

<https://github.com/bitcoin/bitcoin/blob/master/src/test/data/script_valid.json#L26>

So, as I understand this is test for script module of bitcoin core, and this few tests put numbers into stack, then put byte string into stack and process EQUAL opcode.
But in case if numbers should stored in stack as little endian variable int with sign bit (bitcoin wiki) number 0x417a is stored as b'zA' and not as 'Az'.

Number 0x417a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a

will be

zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzA

What type of numbers representation in stack we have to use?

* varint little endian with sign bit ? (bitcoin wiki)
* big endian ?
* 4 byte big endian ? (found on bitcoin source codes class CScriptNum github.com/bitcoin/bitcoin/blob/master/src/script/script.h#L187)

Where I can read exactly specification ?

Thank you

**Tags:** script, specification

> **Comments:**
> **username_1**: It's not interpreted as a number in the example you give, because you're using OP_EQUAL, not OP_NUMEQUAL. The encoding for numbers doesn't enter into it at all.  
> **username_1**: This is a really good example of how OP_EQUAL and OP_NUMEQUAL differ: https://github.com/bitcoin/bitcoin/blob/master/src/test/data/script_valid.json#L372  
> **username_0**: Thank you for quick reply, could you tell me what excatly format of integer numbers using in stack in case if using opcodes works with numbers? Is the correct specification on bitcoin wiki?  
> **username_0**: https://github.com/richardkiss/pycoin/blob/master/pycoin/intbytes.py using BIG endian unsigned format ( I think its wrong)  
> **username_0**: https://github.com/petertodd/python-bitcoinlib/blob/master/bitcoin/core/_bignum.py  using little endian varing with sign bit like on bitwiki . Is this correct?  

---

## 0 answers

