+
1
|
list
|
skin
|
login
|
editor
α-wwwiki
::
digits
user:none
(8336 bytes)
_h1 digits _p Just for the "fun" and in order to illustrate the use of "input" function. Enter any text, choose the numeral basis (between 2 and 36), then click on "{b save in the memory}". {input {@ id="text" type="text" value="Amélie Poulain loves ze lambdaway !" style="width:92%"}} {input {@ id="base" type="text" value="2" style="width:20px"}} {input {@ type="submit" value="save in the memory" onclick="°° function translate( str, base ) { for (var digits = '', i = 0; i< str.length; i++) { var j = (i < 10)? ('0'+i) : i; var d = str.charCodeAt(i).toString(base); if (base == 2) { var long = d.length; var del = 8-long; if (long < 8) for (var k=0; k < del; k++) d = '0' + d; } digits += '\n'+j+': ' + d; } return digits; } getId('output').innerHTML = translate( getId('text').value, getId('base').value ); °°"}} {hr} {pre {@ id="output" style="text-align:left; width:100px; display:inline-block;"}} {pre {@ style="text-align:left; width:100px; display:inline-block; vertical-align:top;"} DATA 00: 01000001 01: 01101101 02: 11101001 03: 01101100 04: 01101001 05: 01100101 06: 00100000 07: 01010000 08: 01101111 09: 01110101 10: 01101100 11: 01100001 12: 01101001 13: 01101110 14: 00100000 15: 01101100 16: 01101111 17: 01110110 18: 01100101 19: 01110011 20: 00100000 21: 01111010 22: 01100101 23: 00100000 24: 01101100 25: 01100001 26: 01101101 27: 01100010 28: 01100100 29: 01100001 30: 01110111 31: 01100001 32: 01111001 33: 00100000 34: 00100001 } {pre {@ style="text-align:left; width:100px; display:inline-block;vertical-align:top;"} CODE 00: 01100110 01: 01110101 02: 01101110 03: 01100011 04: 01110100 05: 01101001 06: 01101111 07: 01101110 08: 00100000 09: 01110100 10: 01110010 11: 01100001 12: 01101110 13: 01110011 14: 01101100 15: 01100001 16: 01110100 17: 01100101 18: 00101000 19: 00100000 20: 01110011 21: 01110100 22: 01110010 23: 00101100 24: 00100000 25: 01100010 26: 01100001 27: 01110011 28: 01100101 29: 00100000 30: 00101001 31: 00100000 32: 01111011 33: 00100000 34: 00100000 35: 00100000 36: 01100110 37: 01101111 38: 01110010 39: 00100000 40: 00101000 41: 01110110 42: 01100001 43: 01110010 44: 00100000 45: 01100100 46: 01101001 47: 01100111 48: 01101001 49: 01110100 50: 01110011 51: 00100000 52: 00111101 53: 00100000 54: 00100111 55: 00100111 56: 00101100 57: 00100000 58: 01101001 59: 00100000 60: 00111101 61: 00100000 62: 00110000 63: 00111011 64: 00100000 65: 01101001 66: 00111100 67: 00100000 68: 01110011 69: 01110100 70: 01110010 71: 00101110 72: 01101100 73: 01100101 74: 01101110 75: 01100111 76: 01110100 77: 01101000 78: 00111011 79: 00100000 80: 01101001 81: 00101011 82: 00101011 83: 00101001 84: 00100000 85: 01111011 86: 00100000 87: 00100000 88: 00100000 89: 00100000 90: 00100000 91: 01110110 92: 01100001 93: 01110010 94: 00100000 95: 01101010 96: 00100000 97: 00111101 98: 00100000 99: 00101000 100: 01101001 101: 00100000 102: 00111100 103: 00100000 104: 00110001 105: 00110000 106: 00101001 107: 00111111 108: 00100000 109: 00101000 110: 00100111 111: 00110000 112: 00100111 113: 00101011 114: 01101001 115: 00101001 116: 00100000 117: 00111010 118: 00100000 119: 01101001 120: 00111011 121: 00100000 122: 00100000 123: 00100000 124: 00100000 125: 00100000 126: 01110110 127: 01100001 128: 01110010 129: 00100000 130: 01100100 131: 00100000 132: 00111101 133: 00100000 134: 01110011 135: 01110100 136: 01110010 137: 00101110 138: 01100011 139: 01101000 140: 01100001 141: 01110010 142: 01000011 143: 01101111 144: 01100100 145: 01100101 146: 01000001 147: 01110100 148: 00101000 149: 01101001 150: 00101001 151: 00101110 152: 01110100 153: 01101111 154: 01010011 155: 01110100 156: 01110010 157: 01101001 158: 01101110 159: 01100111 160: 00101000 161: 01100010 162: 01100001 163: 01110011 164: 01100101 165: 00101001 166: 00111011 167: 00100000 168: 00100000 169: 00100000 170: 00100000 171: 00100000 172: 01101001 173: 01100110 174: 00100000 175: 00101000 176: 01100010 177: 01100001 178: 01110011 179: 01100101 180: 00100000 181: 00111101 182: 00111101 183: 00100000 184: 00110010 185: 00101001 186: 00100000 187: 01111011 188: 00100000 189: 00100000 190: 00100000 191: 00100000 192: 00100000 193: 00100000 194: 00100000 195: 01110110 196: 01100001 197: 01110010 198: 00100000 199: 01101100 200: 01101111 201: 01101110 202: 01100111 203: 00100000 204: 00111101 205: 00100000 206: 01100100 207: 00101110 208: 01101100 209: 01100101 210: 01101110 211: 01100111 212: 01110100 213: 01101000 214: 00111011 215: 00100000 216: 00100000 217: 00100000 218: 00100000 219: 00100000 220: 00100000 221: 00100000 222: 01110110 223: 01100001 224: 01110010 225: 00100000 226: 01100100 227: 01100101 228: 01101100 229: 00100000 230: 00111101 231: 00100000 232: 00111000 233: 00101101 234: 01101100 235: 01101111 236: 01101110 237: 01100111 238: 00111011 239: 00100000 240: 00100000 241: 00100000 242: 00100000 243: 00100000 244: 00100000 245: 00100000 246: 00100000 247: 01101001 248: 01100110 249: 00100000 250: 00101000 251: 01101100 252: 01101111 253: 01101110 254: 01100111 255: 00100000 256: 00111100 257: 00100000 258: 00111000 259: 00101001 260: 00100000 261: 00100000 262: 00100000 263: 00100000 264: 00100000 265: 00100000 266: 00100000 267: 00100000 268: 00100000 269: 01100110 270: 01101111 271: 01110010 272: 00100000 273: 00101000 274: 01110110 275: 01100001 276: 01110010 277: 00100000 278: 01101011 279: 00111101 280: 00110000 281: 00111011 282: 00100000 283: 01101011 284: 00100000 285: 00111100 286: 00100000 287: 01100100 288: 01100101 289: 01101100 290: 00111011 291: 00100000 292: 01101011 293: 00101011 294: 00101011 295: 00101001 296: 00100000 297: 00100000 298: 00100000 299: 00100000 300: 00100000 301: 00100000 302: 00100000 303: 00100000 304: 00100000 305: 01100100 306: 00100000 307: 00111101 308: 00100000 309: 00100111 310: 00110000 311: 00100111 312: 00100000 313: 00101011 314: 00100000 315: 01100100 316: 00111011 317: 00100000 318: 00100000 319: 00100000 320: 00100000 321: 00100000 322: 01111101 323: 00100000 324: 00100000 325: 00100000 326: 00100000 327: 00100000 328: 01100100 329: 01101001 330: 01100111 331: 01101001 332: 01110100 333: 01110011 334: 00100000 335: 00101011 336: 00111101 337: 00100000 338: 00100111 339: 01011100 340: 01101110 341: 00100111 342: 00101011 343: 01101010 344: 00101011 345: 00100111 346: 00111010 347: 00100000 348: 00100111 349: 00100000 350: 00101011 351: 00100000 352: 01100100 353: 00111011 354: 00100000 355: 00100000 356: 00100000 357: 01111101 358: 00100000 359: 00100000 360: 00100000 361: 01110010 362: 01100101 363: 01110100 364: 01110101 365: 01110010 366: 01101110 367: 00100000 368: 01100100 369: 01101001 370: 01100111 371: 01101001 372: 01110100 373: 01110011 374: 00111011 375: 00100000 376: 01111101 } {pre {@ style="text-align:left; width:100px; display:inline-block; vertical-align:top;"} Some explanations : 1) In the first column is the representation of the sentence contained in the text field. You can change it. 2) in column DATA is the binary representation of the sentence : « Amélie Poulain loves ze lambdaway ! » 3) in column CODE is the binary represntation of the function translate() which translates the sentence in its binary representation. 4) Do you see any difference in the structure of these informations ? In the computer memory, in the processor unit, in all the devices, in the network, every information shares this unique shape, either it is data or code working on the datas.We can speak of : « Homoiconicity » 5) In the Lisp language, everything shares this form : (first rest) For instance : data : (1 2 3 4 5 6) code : (* 2 3 4 5 6) This wiki page contains some datas and some code sharing the same shape. Code transforms datas and datas can be transformed into code. It's powerful ! }