Code


 
Thread Tools Search this Thread
The Lounge What is on Your Mind? Code
# 1  
Old 10-07-2013
Code

When you trying for work with computers first you see KB (or KiloBytes)and MB (or MegaBytes) all the time but where you does it stand for?Basically it’s a measurement of memory on a computer.
Here i have some examples of what some other numbers and letters look like to the computer:

Code:
0 = 00000000	a = 01100001	L = 01001100
1 = 00000001	v = 01110110	p = 01110000
2 = 00000010	$ = 00100100	z = 01111010

Link deleted.
Moderator's Comments:
Mod Comment The posts by this user almost seem to be real, but the opening statements are incorrect statements of fact. The poster does not respond to comments. This poster has been banned.

Last edited by Don Cragun; 10-21-2013 at 08:28 AM.. Reason: Spam.
# 2  
Old 10-07-2013
Computer systems use binary numbers. That is: the number "two" times itself.

2x2x2x2x2x2x2x2x2x2 = 1024 = 1 K (2^10)

2x2x2x2x2x2x2x2x2x2X2x2x2x2x2x2x2x2x2x2 = 1048576 = M (2^20)

So one Kb (or KB) is 1024 bytes of data in a file
One MB is 1048576 bytes of data in a file.

Since the computer uses only numbers to represent everything, the alphabet and other characters are assigned a number. Capital A=65, 0 (zero number character) = 49.

The definitions exist for EVERY character you can type, including the <enter> key.
The definition of these characters is a world-wide standard, it is called ASCII. When you set your computer to use languages that have complicated sets of glyphs, the new rules (numbers for each glyph) are stored in locale settings. These are special, not ASCII usually.

The default locale is named "C". After the computer language C. That locale uses ASCII.

Computers are all about numbers and number crunching, so everything boils down to how numbers are stored in memory - they are stored as base2 numbers - binary - only ones and zeroes are allowed.
# 3  
Old 10-07-2013
Quote:
Originally Posted by jim mcnamara
... ... ...

Since the computer uses only numbers to represent everything, the alphabet and other characters are assigned a number. Capital A=65, 0 (zero number character) = 49.

The definitions exist for EVERY character you can type, including the <enter> key.
The definition of these characters is a world-wide standard, it is called ASCII. When you set your computer to use languages that have complicated sets of glyphs, the new rules (numbers for each glyph) are stored in locale settings. These are special, not ASCII usually.

The default locale is named "C". After the computer language C. That locale uses ASCII.

Computers are all about numbers and number crunching, so everything boils down to how numbers are stored in memory - they are stored as base2 numbers - binary - only ones and zeroes are allowed.
The C and POSIX standards do not require that the C (and POSIX) Locales be based on the ASCII codeset. The POSIX standards do require that the collation order of the 128 characters in the ASCII codeset is the same as the binary byte order of the ASCII characters no matter what the actual underlying codeset is. This guarantees that if you sort text files that only contain characters from the portable character set (which omits some of the ASCII control characters), the text will sort into the same order on a machine no matter what codeset is underlying the C and POSIX Locales. Note that to make this happen when sorting, you have to compare strings using the locale's collating order (like you get using strcoll()); not the numeric values of bytes (like you get using strcmp()).

There are UNIX branded implementations where the codeset underlying the C and POSIX Locales is a superset of ASCII (such as UTF-8 or one of the ISO 8859-* standards) where all of what Jim said above are true, but there are also implementations where the codeset underlying the C and POSIX Locales is one of the EBCDIC codesets where most of what Jim said above is not true.

Capital A is decimal 65 in ASCII, but it is decimal 193 in EBCDIC. Although in ASCII, the lowercase (uppercase) letters a-z (A-Z) have adjacent increasing values, that is not true in EBCDIC. The standards do, however, require that the 10 decimal digits (0-9) do have adjacent increasing values no matter what the underlying codeset is. When d is an integeral value from 0 through 9 inclusive, the following works to convert d to the corresponding character value in an ASCII based environment:
Code:
48 + d

(note 48; not the 49 Jim listed above) the same conversion in an EBCDIC based environment would be:
Code:
240 + d

But, you can portably write:
Code:
'0' + d

no matter what codeset underlies your C and POSIX Locales.

In ASCII, 'a' + 25 is 'z' and 'A' + 25 is 'Z'; that relationship does not hold in EBCDIC.

Note also that your system's default locale is chosen by your system's administrator and is frequently not the C Locale. However, when a C program enters main, it will be act as if it had made the call:
Code:
setlocale(LC_ALL, "C");

When a program capable of dealing with internationalized environments starts, it should explicitly make the call:
Code:
rc = setlocale(LC_ALL, "");

to set the locale in use to be the system's default locale (if the user hasn't overridden the default) or the locale specified by the user by setting the LANG and LC_* environment variables. And, obviously, the program should verify that the user didn't specify an invalid locale by checking the return code from that call to setlocale().
This User Gave Thanks to Don Cragun For This Post:
# 4  
Old 10-07-2013
To add some confusion. In the disk storage world KB en MB typically stand for 10^3 and 10^6. Also, it is becoming more and more common to use KiB, MiB, GiB (Kibi, Mebi and Gibibytes) etc to explicitly refer to the 2^10, 2^20, 2^30, etc variety and to use the kB, MB and GB for the 10^n variety (with a lower case k). But KB, and MB, etc are still routinely used for the base 2 variety...
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Linux

Go to a line of code , skip few lines of code

Hi , I have a code where i am using a infinite while loop . some thing like below while do if then #go to line 20 fi command 1; command 2; #line 20: sleep 34; (5 Replies)
Discussion started by: Paarth
5 Replies

2. Shell Programming and Scripting

Block of code replacement in Java source code through Unix script

Hi, I want to remove the following code from Source files (or replace the code with empty.) from all the source files in given directory. finally { if (null != hibernateSession && hibernateSession.isOpen()) { //hibernateSession.close(); } } It would be great if the script has... (2 Replies)
Discussion started by: hareeshram
2 Replies

3. UNIX for Dummies Questions & Answers

If ‘922’ Code does not exist on ‘03’ Record, ‘901’ Code will be there instead, move ‘03’ R

01,011600033,011600033,110516,0834,2,90,,2/ 02,011600033,011103093,1,110317,0834,,2/ 03,105581,,015,+00000416418,,,901,+00000000148,,,922,+000000 00354,,/ 03,113806,,015,+00000559618,,,901,+00000000096,,,922,+000000 00621,,/ 88,902,+0000000025218,,/... (1 Reply)
Discussion started by: sgoud
1 Replies

4. Shell Programming and Scripting

translate ksh code to csh code

hi all, Can any 1 help me translate this korn shell code to C shell code : email=$(grep "^$1" $folder/config_2.txt | awk '{print $2'}) In config_2.txt the content is : which mean in korn shell , $1=groupname and $2=email address. Now i need to write in C shell script,when i set the... (2 Replies)
Discussion started by: proghack
2 Replies

5. Programming

how i prepare a c++ code(c code) for implementing my own protocol format

helo my protocol format is given below { destno,mode,no.of packet,pktsize,,pktno,textsize,CRC} description:- { is starting flag destno - 4bytes mode - 1 byte no.of pkt - 4byes pktsize - 6 bytes ... (1 Reply)
Discussion started by: amitpansuria
1 Replies

6. UNIX for Advanced & Expert Users

Return code from PL/SQL Code

Hi Guys, I was just wondering if anybody can help me with this problem. OK, how we can get a value back from PL/SQL Script (not stored procedure/function) See the below example: (for example aaa.sh) #!/bin/ksh VALUE=`sqlplus -s user/password@test_id <<EOF @xxx.sq EOF` echo $VALUE ... (7 Replies)
Discussion started by: Shaz
7 Replies
Login or Register to Ask a Question