Hi! I would like to better understand the data types (uint256) for example, what is the length of this type, in characters, what is the maximum value, is it a hexadecimal value?

Aug 1, 2018, 11:46 AM
Hi. uint256 means what you allocate 256 bits for unsigned int type
an unsigned integer containing n bits can have a value between 0 and 2^n - 1 (which is 2n different values).
sorry. it's not 2n. it's 2^n
you are free to convert this value into different numeral systems
Note: It is important to realize that a uint == uint256. Also, for whatever reason, a uint256 takes less gas to store than a uint8. So, if you are trying to optimize data types as you should, just realize this caveat.
Aug 1, 2018, 12:31 PM
@The_JoshSmith that would be awesome!
Roman Then if im tring x.length (where x is uint256 = to 4) whats the anwer? depending on the value or it has a specific size value like 00000000004
Aug 1, 2018, 12:45 PM
answer is 4. if you try to use number, which need more storage then you did allocate, then you will surely get integer overflow. (if you allocated storage for 5 and try to use 6, u will get 0)
Aug 1, 2018, 12:48 PM
got it!
(the link)
then when we say uint256
it means that i can store a decimal value upt to 2^256-1?
Aug 1, 2018, 12:50 PM
(2^256) -1
yep
Aug 1, 2018, 12:50 PM
in an easier case 2^8 = 255 would be the max value i can store
then if i do 255 + 1, it would be 0 as you said right?
Aug 1, 2018, 12:51 PM
@The_JoshSmith what's the easiest way to get instructions log from runtime?
Aug 1, 2018, 12:52 PM
Max is 255.
Use event logs and don't trigger reverts
Or use error messages in require checks and check the error message
Aug 1, 2018, 3:19 PM
Clear! Thanks!n
Aug 1, 2018, 3:20 PM

© 2024 Draquery.com All rights reserved.