Hi guys...
this is my very first blog.....
I was thinking about what to start with..when my eyes fell on a post in the computer programming group of our clg BESU on fb...where one of my seniors posted a problem regarding storing of large values...like 100! or 4^1000000 etc...
i was thinking how to represent such a large data in a single variable....
when i came through Data structures....i read a book n i realized tht linked list(as u all must be quite familiar with)...can be used to represent it.....
like we can represent a large no lik 987654321 in a doubly linked list as : -
9=8=7=6=5=4=3=2=1
where '=' represents a double linked....
n the structure shud be
struct digit
{
int data;
struct digit* prev;
struct digit* next;
}
so this is the one which i have seen...so far...!!
but i got a diff idea....!
i would like to represent in the same way bt each digit wud be represented with a char rather than an int...!!
the structure wud be : -
struct digit
{
char data;
struct digit* prev;
struct digit* next;
}
seems same as the previous one...??isnt it...??
bt my dear...its not....
in a normal char/int array it wil store '0'-'9' / 0-32768(for 2 bytes)....
the first case wud be the normal n expected one...
whereas the second one is ok....
bt i have got a diff approach...
i thot that the char data wud store ascii characters n their corresponding ascii codes will store our required number....
ok....lets elaborate....
TABLE 1-a
ok so above u can see the most famous ascii table...
if u can observe properly the leftmost column (ascii codes)then you will realize that the ascii characters wid codes from 0-31...cannot be input using the keyboard....
but from ascii code 32...ie its corresponding ascii character - ' ' (space) can be input using keyboard....
and aftr 32 we can input characters from keyboard till ascii codes 126.....ie its ascii char '~' .....
now like hexadecimal whr 0 represnts 0 ......til 'A' represents 10......'F' represents 15....
similarly in my new ALPHANUMERIC NUMBER SYSTEM i want to represent
0 wid 32 s ascii char ie ' '
1 wid 33 s ascii char ie '!'
2 wid 34 s ascii char ie '"'
3 wid 35 s ascii char ie '#'
n so on....
till
94 wid 126 s ascii char ie '~'
the part of ascii table we ll consider is :-
TABLE 1-b
n this is way we can represent (126-32)+1= 95 characters wid jst 1 character....
so the number will start like this:-
TABLE 1-c
so the structure to represent the digit will be-
struct digit
{
char data;
digit* prev;
digit* next;
}
in this blog we will consider only a single character number....ie (from 0-94)
multi character numbers will be taken care of in future blogs...
ok so if d user is asked for entering a number in the new alphanumeric form...
he can enter in form of a string/char... n we will output its corresponding no(from table 1-c) as -
input - A
output - 33
so guys...i hope you liked my idea...
in later blogs i ll discuss about the
simple arithmetic operations
storage of this alphanumeric data..
thank u..!!
Njy Lyf :)
Keep Rocking...!!
this is my very first blog.....
I was thinking about what to start with..when my eyes fell on a post in the computer programming group of our clg BESU on fb...where one of my seniors posted a problem regarding storing of large values...like 100! or 4^1000000 etc...
i was thinking how to represent such a large data in a single variable....
when i came through Data structures....i read a book n i realized tht linked list(as u all must be quite familiar with)...can be used to represent it.....
like we can represent a large no lik 987654321 in a doubly linked list as : -
9=8=7=6=5=4=3=2=1
where '=' represents a double linked....
n the structure shud be
struct digit
{
int data;
struct digit* prev;
struct digit* next;
}
so this is the one which i have seen...so far...!!
but i got a diff idea....!
i would like to represent in the same way bt each digit wud be represented with a char rather than an int...!!
the structure wud be : -
struct digit
{
char data;
struct digit* prev;
struct digit* next;
}
seems same as the previous one...??isnt it...??
bt my dear...its not....
in a normal char/int array it wil store '0'-'9' / 0-32768(for 2 bytes)....
the first case wud be the normal n expected one...
whereas the second one is ok....
bt i have got a diff approach...
i thot that the char data wud store ascii characters n their corresponding ascii codes will store our required number....
ok....lets elaborate....
TABLE 1-a
ok so above u can see the most famous ascii table...
if u can observe properly the leftmost column (ascii codes)then you will realize that the ascii characters wid codes from 0-31...cannot be input using the keyboard....
but from ascii code 32...ie its corresponding ascii character - ' ' (space) can be input using keyboard....
and aftr 32 we can input characters from keyboard till ascii codes 126.....ie its ascii char '~' .....
now like hexadecimal whr 0 represnts 0 ......til 'A' represents 10......'F' represents 15....
similarly in my new ALPHANUMERIC NUMBER SYSTEM i want to represent
0 wid 32 s ascii char ie ' '
1 wid 33 s ascii char ie '!'
2 wid 34 s ascii char ie '"'
3 wid 35 s ascii char ie '#'
n so on....
till
94 wid 126 s ascii char ie '~'
the part of ascii table we ll consider is :-
TABLE 1-b
n this is way we can represent (126-32)+1= 95 characters wid jst 1 character....
so the number will start like this:-
TABLE 1-c
so the structure to represent the digit will be-
struct digit
{
char data;
digit* prev;
digit* next;
}
in this blog we will consider only a single character number....ie (from 0-94)
multi character numbers will be taken care of in future blogs...
ok so if d user is asked for entering a number in the new alphanumeric form...
he can enter in form of a string/char... n we will output its corresponding no(from table 1-c) as -
input - A
output - 33
so guys...i hope you liked my idea...
in later blogs i ll discuss about the
simple arithmetic operations
storage of this alphanumeric data..
thank u..!!
Njy Lyf :)
Keep Rocking...!!
I like the idea!
ReplyDeleteWhy don't you post a sample program to take inputs in this format, that will give a more clear picture of your concept.
p.s. There are some typos in the second last para.
@alfaz i l do so in the next blog.... :)
ReplyDeleteNice work mahn..
ReplyDeleteThanks for sharing.Greets!
@abhishek Cheers !! :)
ReplyDelete