And/es: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: And/es
| Old | New | Line | |
|---|---|---|---|
| 1 | + | ## Operación booleana | |
| 2 | + | ||
| 3 | + | Boolean **And** produce un valor de [[True|true]] si y sólo si ambos operandos booleanos son verdaderos. | |
| 4 | + | ||
| 5 | + | ### Tabla de True | |
| 6 | + | ||
| 7 | + | | A | B | A and B | | |
| 8 | + | |-----------|-----------|---------| | |
| 9 | + | | false | false | false | | |
| 10 | + | | false | true | false | | |
| 11 | + | | true | false | false | | |
| 12 | + | | true | true | true | | |
| 13 | + | ||
| 14 | + | ## Operación a bit | |
| 15 | + | ||
| 16 | + | Logical **And** (también conocido como Bitwise And) requiere operandos ordinales y establece un bit en la variable de resultado a 1 si y sólo si ambos bits correspondientes en los operandos son 1. | |
| 17 | + | ||
| 18 | + | ### Es potencia de dos | |
| 19 | + | ||
| 20 | + | ``` pascal | |
| 21 | + | function EsPotenciaDeDos ( const unValor : longint ): boolean; | |
| 22 | + | var | |
| 23 | + | x : longint; | |
| 24 | + | b : boolean; | |
| 25 | + | begin | |
| 26 | + | b := false; | |
| 27 | + | if unValor <> 0 then | |
| 28 | + | begin | |
| 29 | + | x := unValor - 1; | |
| 30 | + | x := x and unValor; | |
| 31 | + | if x = 0 then b := true; | |
| 32 | + | end; | |
| 33 | + | result := b; | |
| 34 | + | end; | |
| 35 | + | ``` | |
| 36 | + | ||
| 37 | + | Si llamas a EsPotenciaDeDos(4) entonces obtienes True. Si llamas a EsPotenciaDeDos(5) obtienes False. | |
| 38 | + | ||
| 39 | + | ## También ver | |
| 40 | + | ||
| 41 | + | - [[Not]] | |
| 42 | + | - [[Or]] | |
| 43 | + | - [[Shl]] | |
| 44 | + | ||
| 45 | + | - [[Const]] | |
| 46 | + | - [[Function]] | |
| 47 | + | - [[Integer]] | |
| 48 | + | ||
| 49 | + | - [[Shl|Clear a bit]] | |
| 50 | + | - [[Bit manipulation]] | |
| 51 | + | ||
| 52 | + | --- | |
| 53 | + | *From the Free Pascal wiki, page "And/es", as it stood on 2020-01-26 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
