Variables y números binarios

Variables

Las variables contienen un valor representado por un código numérico o alfanumérico. El sistema de numeración que usamos las personas es un sistema decimal. Esto quiere decir que existen 10 símbolos diferentes los cuales son combinados para construir cualquier número. Estos 10 símbolos son los número del 0 al 9. Por ejemplo para representar el número 121 en decimal se hace la siguiente operación:

1×102+2×101+1×100=100+20+1=121

En el ejemplo se puede observar que para que para obtener el número se toma el símbolo de cada posición (que puede ser cualquiera entre 0 y 9), se multiplica por la base (10 para sistema decimal por sus 10 símbolos) elevada a la posición en que se encuentre el símbolo comenzando desde el número 0. En otras palabras el símbolo en la posición cero se multiplica por 1 (100 =1), el símbolo en la segunda posición se multiplica por 10 (101=10), el símbolo de la tercera posición se multiplica por 100 (102=100) y así sucesivamente.

Sistema de numeración binario

El sistema de numeración binario funciona de forma similar al sistema de numeración decimal, con la diferencia que en el sistema binario la cantidad de símbolos son dos, el 0 y el 1. Por ejemplo para representar el número 121 en binario se hace la siguiente operación:

1×26+1×25+1×24+1×23+0x22+0x21+1×20= 64+32+16+8+0+0+1=121

La representación del número 121 en binario es 1111001b. La “b” al final es para indicar que la representación está en binario y diferenciarlos de un millón ciento once mil uno en decimal. En este punto se pueden estar preguntando cómo se obtuvo el patrón de unos y ceros para la representación del 121 en binario, hay varias formas para hacer esto, una muy sencilla es ir colocando 1’s de izquierda a derecha progresivamente, si al colocar un 1 en determinada posición y el valor supera al valor buscado, entonces esa posición lleva un valor de cero. Para el ejemplo anterior si comenzamos con un 1 en la posición 7 el valor obtenido es 127 el cual es mayor que 121, por esa razón comenzamos con un 1 en la posición 6. La siguiente tabla resume el procedimiento

Posición Suma acumulada Valor en la posición
6 2posición=26=64 1
5 64+32=96 1
4 96+16=112 1
3 112+8=120 1
2 120+4=124 > 121 0
1 120+2=122 >121 0
0 120+1=121 1

 

Numero de bits

A cada posición (o dígito) de un número binario también se le llama bit, en el caso del ejemplo anterior el número 121 es representado con 7 bits. El número de bit es importante por determina el rango de valores que puede tener un número binario, por ejemplo, un número de 8 bits puede tener un valor que va desde 0 hasta 255 (2n-1), donde n es el número de bits). Desde el punto de vista de la electrónica, el hecho de que cada dígito o bit tenga sólo dos valores es muy importante, esto le da una simplicidad a cada dígito que puede ser representado como un interruptor abierto o cerrado, o con un transistor en corte o saturación, o con un LED prendido o pagado entre otras opciones.

Códigos

La combinaciones de 1’s y 0’s también sirven para representar códigos, como por ejemplo el código ASCII. Por ejemplo el número 01111001b representa el número 121, representa la letra “y” en el código ASCII y representa el número 79 en código BCD entre otros.

Tipos de variables

La importancia de los números binarios en el uso de los PLC radica en el hecho que los microprocesadores con los cual se construyen realizan todos sus operaciones usando como argumentos variables binarias. Estas variables binarias puede ser de diferentes tipos, los más usados son: booleana o bit, enteros, punto flotante y caracteres o cadena de caracteres. Las variables enteras y de punto flotante son llamadas variables analógicas.

Variables Booleanas

También llamadas lógicas o de bit, son representaciones binarias de un solo bit o con un solo dígito, en tal sentido, sólo pueden tener los valores de 0 o 1, que normalmente son interpretados como falso o verdadero respectivamente.

Enteros

Son registros de memoria que pueden almacenar números de n bit, donde n, típicamente, es múltiplo de 2. Así podemos tener variables enteras de 4 bits, 8 bits, 16 bits, 32 bits y 64 bits. El número de bits, como se mencionó antes, determina el rango de los valores que puede tener la variable.

Cuando se representa números binarios, a veces se representas números positivos y el cero, a este código se le denomina binario puro; pero también se pueden representar valores negativos, positivos y el cero, a este código se le denomina binario en complemento a dos. Dependiendo del número de bits se le puede asignar un nombre al entero, por ejemplo un entero de 8 bit es también llamado byte. La siguiente tabla muestra el un resumen de numero de bit y su rango.

Numero de bits Rango binario Rango binario complemento a dos
4 (nibble) 0 a 15 -8 a 7
8 (byte) 0 a 255 -128 a +127
16 0 a 65.535 -32,768 a +32,767
32 0 a 4.294.967.295 -2,147,483,648 a +2,147,483,647
64 0 a 18.446.744.073.709.551.615 -9.223.372.036.854.775.808 a +9.223.372.036.854.775.807

Punto flotante

También llamadas reales, pueden contener número con decimales. La representación en punto flotante se hace con estándares como IEEE 754. Con este estándar y precisión simple se pueden representar número desde  -1.17549449×10-38 hasta 3.40282346×1038.

Carácter

Un carácter es un símbolo de la tabla ASCII (letras, números, símbolos y caracteres de control) representado con 8 bits, a la concatenación de varios caracteres se le llama cadena de caracteres y se usan para formar palabra o frases.

62 Comentarios

  1. usmle step 2 ck prep course

    Excellent way of describing, and nice piece of writing to obtain facts about my presentation subject matter, which i am going to present in institution of higher education.

    Responder
  2. Explore now

    stromectol ebay – fda ivermectin ivermectin 1

    Responder
  3. nsfw ai

    Thank you ever so for you article.Really looking forward to read more. Great.

    Responder
  4. nsfw ai chat

    Hey, thanks for the blog. Really Great.

    Responder
  5. SheTopper Eyewear

    I am so grateful for your blog post. Fantastic.

    Responder
  6. pyproxy download

    I value the article. Want more.

    Responder
  7. Plate Compactor

    Im grateful for the article post.Thanks Again. Much obliged.

    Responder
  8. FTTx solution provider

    Very good blog.Really looking forward to read more.

    Responder
  9. 实用文

    Thank you ever so for you article.Really looking forward to read more. Cool.

    Responder
  10. Vmjddf

    buy clavulanate sale – buy cymbalta for sale buy cymbalta online cheap

    Responder
  11. ice water hack recipe

    What’s up mates, its fantastic paragraph about teachingand fullyexplained, keep it up all the time.

    Responder
  12. Ikugxt

    order neurontin 100mg for sale – anafranil 25mg generic buy generic sporanox

    Responder
  13. best security systems for homes in indianapolis

    Some times its a pain in the ass to read what people wrote but this web site is rattling user friendly! .

    Responder
  14. 派傳單

    What’s up, its fastidious post about media print, we all understand media is a wonderful sourceof data.

    Responder
  15. Desierto de la Tatacoa con niños

    Looking forward to reading more. Great article.Really looking forward to read more. Keep writing.

    Responder
  16. best geek bar flavors

    Enjoyed every bit of your article post.Thanks Again. Want more.

    Responder
  17. Commodore 64 Games

    Wow that was unusual. I just wrote an really long comment but after I clicked submit my comment didn’t show up. Grrrr… well I’m not writing all that over again. Anyhow, just wanted to say fantastic blog!

    Responder
  18. gas mask

    Thank you ever so for you blog.Really thank you!

    Responder
  19. Wkqktc

    order prednisolone 40mg without prescription – buy azipro 250mg pills generic prometrium

    Responder
  20. 출장마사지

    Major thanks for the article.Really looking forward to read more. Awesome.

    Responder
  21. Betty and Veronica

    Howdy! This post couldn’t be written any better!Reading this post reminds me of my good old room mate! He always kept talking about this.I will forward this post to him. Fairly certain he will have a good read.Thanks for sharing!

    Responder
  22. Wnayoc

    buy azithromycin 250mg – cheap tinidazole order nebivolol 20mg online cheap

    Responder
  23. salt trick for men reviews

    chloroquine otc hydroxychloroquine update today hsq medical abbreviation

    Responder
  24. onlyfans 18+

    I’ll right away clutch your rss as I can’t find your e-mail subscription link or newsletter service. Do you’ve any? Please let me recognize so that I may subscribe. Thanks.

    Responder
  25. togel4d register

    I like what you guys are usually up too. Such clever work and exposure!Keep up the excellent works guys I’ve included you guys toour blogroll.

    Responder
  26. 18+ porn

    What’s Hot On MediaKombat: Video – Famous Dex – Crazy me(shot by @cadencampise)

    Responder
  27. crazy porn

    Its actually a great and helpful piece of information. I am happy that you just shared this useful information with us. Please keep us up to date like this. Thanks for sharing.

    Responder
  28. usa porn

    Bardzo interesujące informacje! Idealnie to, czego szukałem! przenośny generator tlenu.

    Responder
  29. Baixi Can Industry

    I really liked your blog article.Thanks Again.

    Responder
  30. Zhenxi Metal Packaging

    This is one awesome blog.Thanks Again. Fantastic.

    Responder
  31. Mua like

    These are genuinely wonderful ideas in aboutblogging. You have touched some pleasant things here. Any waykeep up wrinting.My blog – MaxBHB

    Responder
  32. water bong

    Im obliged for the blog post.Much thanks again. Keep writing.

    Responder
  33. squid porn

    That is a very good tip especially to those fresh to the blogosphere. Short but very precise infoÖ Thanks for sharing this one. A must read post!

    Responder
  34. Hack like

    I like foregathering useful information, this post has gotme even more info!My blog post … Instant Keto Review

    Responder
  35. Najlepsze kasyna online w Polsce

    Hey, have you ever before wondered to write regarding Nintendo or PS handheld?

    Responder
  36. fillersfairy

    Looking forward to reading more. Great article.

    Responder
  37. therapeutic and regular massagers

    Really appreciate you sharing this blog article.Really looking forward to read more.

    Responder
  38. linkin love ai

    Fantastic blog article. Cool.

    Responder
  39. bokep jahanam

    I’m truly enjoying the design and layout of your blog. It’s a very easy on the eyes which makes it much more pleasant for me to come here and visitmore often. Did you hire out a designer to createyour theme? Exceptional work!

    Responder
  40. linkin love

    Awesome blog.Really looking forward to read more. Awesome.

    Responder
  41. Dumpster rental near me

    Very neat blog article.Thanks Again. Awesome.

    Responder
  42. china Dropshipping

    Major thankies for the article post.Much thanks again. Keep writing.

    Responder
  43. biyapay官网

    This is one awesome blog post.Really thank you! Will read on…

    Responder
  44. Distribution Transformer

    wow, awesome article.Really looking forward to read more.

    Responder
  45. CNC Milling Parts

    I really liked your article post.Much thanks again. Great.

    Responder
  46. xxx porn

    Thanks for finally talking about >Qui Chế của Diễn Đàn Vijaya – ILIMOCHAMPA

    Responder
  47. cheap seo

    fantastic issues altogether, you simply won a new reader.What could you suggest about your submit that you just made some days ago?Any positive?

    Responder
  48. mua like facebook

    These are genuinely great ideas in concerning blogging. You have touched some pleasant points here. Any way keep up wrinting.

    Responder
  49. 貼街招

    It’s hard to come by knowledgeable people for this subject, however, you sound like you know what you’re talking about! Thanks

    Responder
  50. bokep mantap

    chloroquine otc hydroxychloroquine update today hsq medical abbreviation

    Responder
  51. cod voucher

    I do not even know how I stopped up right here, but I believed this publish was once good. I don’t understand who you might be however definitely you’re going to a famous blogger for those who are not already 😉 Cheers!

    Responder
  52. medartix.com

    Really enjoyed this post.Much thanks again. Want more.

    Responder
  53. Fosdyb

    amoxil online buy – amoxicillin tablets order ipratropium without prescription

    Responder
  54. social anxiety treatment

    F*ckin’ tremendous issues here. I am very glad to peer your article. Thank you so much and i am looking forward to contact you. Will you kindly drop me a e-mail?

    Responder
  55. Nuateo

    purchase isotretinoin – buy zyvox 600 mg pills oral linezolid 600mg

    Responder
  56. Tnttjq

    ivermectin cost – carbamazepine 400mg price order carbamazepine pill

    Responder
  57. conversion probability

    Hi, just required you to know I he added your site to my Google bookmarks due to your layout. But seriously, I believe your internet site has 1 in the freshest theme I??ve came across. It extremely helps make reading your blog significantly easier.

    Responder
  58. la olada

    A powerful share, I just given this onto a colleague who was doing a little bit evaluation on this. And he in truth bought me breakfast as a result of I discovered it for him.. smile. So let me reword that: Thnx for the treat! However yeah Thnkx for spending the time to debate this, I feel strongly about it and love studying more on this topic. If possible, as you grow to be experience, would you mind updating your blog with extra details? It is extremely useful for me. Big thumb up for this blog put up!

    Responder
  59. lawn mow near me

    Hello there, I found your blog via Google while looking for a related topic, your site came up, it looks good. I have bookmarked it in my google bookmarks.

    Responder
  60. Branko Kajtazi

    I conceive this website holds some real superb information for everyone : D.

    Responder
  61. gelules cannabidiol

    It’s really a great and useful piece of information. I am glad that you simply shared this helpful information with us. Please stay us informed like this. Thanks for sharing.

    Responder
  62. zoritoler imol

    I always was interested in this subject and stock still am, thanks for putting up.

    Responder

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *