Forum > General

How to force the not operator to return a byte

<< < (2/14) > >>

MarkMLl:

--- Quote from: Roland57 on May 14, 2021, 07:04:15 pm ---Your proposition seems to solve the problem, but I don't understand it.  :)

--- End quote ---

Neither do I, since according to https://www.freepascal.org/docs-html/current/ref/refsu4.html#x26-250003.1.1 the largest ShortInt is 127.

MarkMLl

lucamar:

--- Quote from: MarkMLl on May 14, 2021, 07:19:16 pm ---
--- Quote from: Roland57 on May 14, 2021, 07:04:15 pm ---Your proposition seems to solve the problem, but I don't understand it.  :)
--- End quote ---
Neither do I, since according to https://www.freepascal.org/docs-html/current/ref/refsu4.html#x26-250003.1.1 the largest ShortInt is 127.
--- End quote ---

The quid of the question is that ShortInt forces the constant to be interpreted as/converted to a signed byte. To be fair, though, casting to Byte should work equally well (or better).

Roland57:

--- Quote from: lucamar on May 14, 2021, 07:45:12 pm ---To be fair, though, casting to Byte should work equally well (or better).

--- End quote ---

Should, maybe, but doesn't.  :)


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---const  a = byte(128);  b = 64;  c = byte(not(a or b));  beginend.

--- Quote ---Warning: range check error while evaluating constants (-193 must be between 0 and 255)
--- End quote ---

winni:
Hi!

Solution is in reply #1 above.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---b = byte(64);
Winni

Roland57:

--- Quote from: winni on May 14, 2021, 08:46:33 pm ---Solution is in reply #1 above.

--- End quote ---

Thanks, but...


--- Quote ---Warning: range check error while evaluating constants (-193 must be between 0 and 255)
--- End quote ---

 :-\

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version