# 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:** 1\
**Showing post:** 2

<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.

---

_[View the full topic](https://forum.algorand.co/t/how-to-convert-1-to-1-in-teal/3585)._
