# How to convert "1" to 1 in Teal?

**URL:** <https://forum.algorand.co/t/how-to-convert-1-to-1-in-teal/3585>\
**Category:** General\
**Tags:** teal\
**Created:** [June 19, 2021, 2:09pm UTC](https://forum.algorand.co/t/how-to-convert-1-to-1-in-teal/3585 "2021-06-19T14:09:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alg](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@Alg](https://forum.algorand.co/u/Alg)\
**Post date:** [June 19, 2021, 2:09pm UTC](https://forum.algorand.co/t/how-to-convert-1-to-1-in-teal/3585/1 "2021-06-19T14:09:32Z")

</div>

How can I convert `Bytes("1")` to `Int(1)` using PyTeal? `Assert(Btoi(Bytes("1")) == Int(1))` gives `logic eval error: assert failed`. That’s consistent with the warning “operations are not meant to convert between human-readable strings and numbers” from here: [Data Types and Constants — PyTeal documentation](https://pyteal.readthedocs.io/en/latest/data_type.html).

So, if my URL is just a number (saved as Bytes) how can use it in Teal arithmetic?

---

<div class="post-metadata">

**Author:** ![fabrice](https://avatars.discourse-cdn.com/v4/letter/f/5fc32e/32.png) [@fabrice](https://forum.algorand.co/u/fabrice)\
**Post date:** [June 19, 2021, 3:44pm UTC](https://forum.algorand.co/t/how-to-convert-1-to-1-in-teal/3585/2 "2021-06-19T15:44:21Z")

</div>

To convert a single digit, something like

```python
Btoi(Bytes("1")) - Int(48)

```

should work. 48 is the ASCII value of “0”. (See [ASCII - Wikipedia](https://en.wikipedia.org/wiki/ASCII#Printable_characters))

If you need to convert a multidigit number, then you most likely need to extract each digit one by one (using `GetByte`), convert them to an integer as above, and reconstruct the resulting decimal number. With two digits (not tested but gives the idea):

```python
def digitStringToUint(s):
    return Btoi(s) - Int(48)

numberAsString = Bytes("42")
numberAsUint = (digitStringToUint(GetBytes(numberAsString, Int(0)))) * Int(10) \
     + (digitStringToUint(GetBytes(numberAsString, Int(1))))

```

Using TEAL v4, you may even create a loop to handle any number of digits, but it’s not yet available to use in PyTEAL to my knowledge.

Note: I’ve not tested the code above. So it may requires some tweaks.
