Solidity Bytes Comparison

Solidity Bytes Comparison

Manage alerts

Loading saved threads...

farhankhwaja · External communityPost link
External question — Ethereum Stack Exchange Author: farhankhwaja Original post: https://ethereum.stackexchange.com/questions/32465 License: CC BY-SA 3.0 — https://creativecommons.org/licenses/by-sa/3.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I was going through the Create Your Own CryptoCurrency documentation and got stuck at the proofOfWork section. In this, they try to do a check i.e. require(n >= bytes(difficulty)) //Check if its under difficulty I wanted to understand, what kind of comparison is being done here? Is is byte-to-byte comparison? Is there some conversion happening before the check? Or, its just a length check (which I think isn't the case, but just to be sure, I added it here). If someone can point me to the right resource on the same.
Quote
Report
Adam Schindler · External communityPost link
External answer — Ethereum Stack Exchange Author: Adam Schindler Original post: https://ethereum.stackexchange.com/a/32468 License: CC BY-SA 3.0 — https://creativecommons.org/licenses/by-sa/3.0/ Adaptation: HTML converted to plain text; contact email addresses removed. if n is greater then or equals to the number of bytes in the difficulty then it will be TRUE statement. Bytes function in python explained: Return a new “bytes” object, which is an immutable sequence of integers in the range 0 <= x < 256. bytes ex: var n = 16 var difficulty = 0x10 var bytes = bytes(difficulty) // 16 n >= bytes is true
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External question — Ethereum Stack Exchange Author: farhankhwaja Source score (net votes, not local likes): 1 Original post: https://ethereum.stackexchange.com/questions/32465 License: CC BY-SA 3.0 — https://creativecommons.org/licenses/by-sa/3.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I was going through the Create Your Own CryptoCurrency documentation and got stuck at the proofOfWork section. In this, they try to do a check i.e. require(n >= bytes(difficulty)) //Check if its under difficulty I wanted to understand, what kind of comparison is being done here? Is is byte-to-byte comparison? Is there some conversion happening before the check? Or, its just a length check (which I think isn't the case, but just to be sure, I added it here). If someone can point me to the right resource on the same.

Cancel quote

Checking account access…