(Redirected from () is greater than () (block))

The correct title of this article is () > (). The Scratch Wiki uses this different title because of technical restrictions.
() > ()
() > ()
Category Operators
Type Boolean
Introduced in 11Oct03

The () > () block is an Operators block and a Boolean block. The block reports true if the first value is greater than the second value and false otherwise.

This block can compare both numbers and strings, which are ordered alphabetically. In Scratch 1.3 and previous versions, it only accepted numbers.

Example Uses

Some common uses for the () > () block are below:

if <(score 1) > (score 2)> then
    say [Player 1 wins!]
else
    say [Player 2 wins!]
end
if <(score) > (☁ high score)> then
    set [☁ high score v] to (score)
end

Comparison

Comparing Numbers

Numbers will be compared as expected unless they are very large:

<(101) > (100)> // returns true
<(100000000000000001) > (100000000000000000)> // returns false

There is a workaround to this:

<(join (100000000000000001) (a)) > (join (100000000000000000) (a))> // returns true

This works because it forces Scratch to do a text comparison instead of a number comparison, which is more accurate at the cost of a small amount of performance.

Comparing Text

Text is compared alphabetically:

<[b] > [a]> // returns true
<[a] > [b]> // returns false

The Empty Value

The empty value will never be considered larger than other values:

<(10) > []> // returns true
<[] > (10)> // returns false

Workaround

Main article: List of Block Workarounds

The block can be replicated with the following code:

<(b) < (a)>

See Also

Cookies help us deliver our services. By using our services, you agree to our use of cookies.