# Large u256 literals

**URL:** <https://forum.fuel.network/t/large-u256-literals/3661>\
**Category:** Rust SDK\
**Created:** [November 19, 2023, 8:08pm UTC](https://forum.fuel.network/t/large-u256-literals/3661 "2023-11-19T20:08:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![FossilFrank](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/fossilfrank/32/1008_2.png) [@FossilFrank](https://forum.fuel.network/u/FossilFrank)\
**Post date:** [November 19, 2023, 8:08pm UTC](https://forum.fuel.network/t/large-u256-literals/3661/1 "2023-11-19T20:08:43Z")

</div>

I’m trying to define a large number in a Sway unit test, but getting the following issue:

```rust
280 | let expected: u256 = 160149899619106589403934712464197979;
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ int literal out of range

```

How can I define large integers?

---

<div class="post-metadata">

**Author:** ![diyahir](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/diyahir/32/1075_2.png) [@diyahir](https://forum.fuel.network/u/diyahir)\
**Post date:** [November 20, 2023, 9:31am UTC](https://forum.fuel.network/t/large-u256-literals/3661/2 "2023-11-20T09:31:52Z")

</div>

> [@FossilFrank](#):
>
> I’m trying to define a large number in a Sway unit test, but getting the following issue:
> 
> ```auto
> 
> ```

> <https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/u256.sw>

```code
pub struct U256 {
    /// The most significant 64 bits of the `U256`.
    a: u64,
    /// The 65-128th most significant bits of the `U256`.
    b: u64,
    /// The 129-192nd most significant bits of the `U256`.
    c: u64,
    /// The 193-256th most significant bits of the `U256`.
    d: u64,
}

```

I don’t think it can just take the raw number, I believe you need to decompose your number into 4 64 bit pieces and then reconstruct it

---

<div class="post-metadata">

**Author:** ![FossilFrank](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/fossilfrank/32/1008_2.png) [@FossilFrank](https://forum.fuel.network/u/FossilFrank)\
**Post date:** [November 20, 2023, 8:06pm UTC](https://forum.fuel.network/t/large-u256-literals/3661/4 "2023-11-20T20:06:38Z")

</div>

I’m trying to use the native `u256`, not the `U256` library.

I worded around it by converting to hex and using the `0x1234u256` notation. But would still be nice to have decimal literals as well.

---

<div class="post-metadata">

**Author:** ![calldelegation](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/calldelegation/32/1484_2.png) [@calldelegation](https://forum.fuel.network/u/calldelegation)\
**Post date:** [November 20, 2023, 10:46pm UTC](https://forum.fuel.network/t/large-u256-literals/3661/5 "2023-11-20T22:46:49Z")

</div>

> [@FossilFrank](#):
>
> `u256`

Yes, @FossilFrank, that is the correct way to do it. I will bring this up with the team to discuss implementing decimal literals.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex022/uploads/fuel/original/2X/5/57d5a345cc15a64b636e0d56e042857f8a0e80b1.png) [@system](https://forum.fuel.network/u/system)\
**Post date:** [December 11, 2023, 6:46pm UTC](https://forum.fuel.network/t/large-u256-literals/3661/6 "2023-12-11T18:46:50Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
