By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,486 Members | 2,169 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,486 IT Pros & Developers. It's quick & easy.

Text versus Number field.

P: n/a
I see other posts where some say fields that will hold a number with
leading zeros should be stored as text instead of numbers.

This is very inefficient though, as a string of digit characters takes
up much more memory than a 32bit or even a 64bit int.

Storing as a number still allows for formatting when displaying the
number, correct?

I am creating a table and would like opinions regarding this please.

Nov 13 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
I work for a telephone company and there is a great deal of difference
between local UK numbers (one leading zero), international numbers
(double zero) local numbers (no leading zeros).

Yes i know that you could have an indicator but it is far simpler to
hold numbers in text format for this purpose.

Its possible to argue the case all over the place but experience has
shown me that text for phone numbers always works best.

Just a thought...

Rob.

Nov 13 '05 #2

P: n/a
sh******@cs.fsu.edu wrote:
I see other posts where some say fields that will hold a number with
leading zeros should be stored as text instead of numbers.

This is very inefficient though, as a string of digit characters takes
up much more memory than a 32bit or even a 64bit int.

Storing as a number still allows for formatting when displaying the
number, correct?

I am creating a table and would like opinions regarding this please.


It depends. If there is a requirement to store both of these...

012
0056

....Then a format of a number field cannot do the job. Also if...

012
12
0012

....need to be treated as different entries then a number field cannot do the
job.

The performance differences between using text versus number are largely
theoretical these days. Yes if you were doing massive calculations and ran
a series of timed loops you would see a difference. In any "normal"
situation you will not.

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #3

P: n/a
sh******@cs.fsu.edu wrote in
news:11*********************@g14g2000cwa.googlegro ups.com:
I see other posts where some say fields that will hold a
number with leading zeros should be stored as text instead of
numbers.

This is very inefficient though, as a string of digit
characters takes up much more memory than a 32bit or even a
64bit int.

Storing as a number still allows for formatting when
displaying the number, correct?

I am creating a table and would like opinions regarding this
please.

Rule #1:
If you will add, divide, multiply or divide this number then
store it as a number.
else
store it as a string
endif

If leading zeroes are important, I suspect that the else
condition will apply.

--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #4

P: n/a
sh******@cs.fsu.edu wrote:
I see other posts where some say fields that will hold a number with
leading zeros should be stored as text instead of numbers.
There are no numbers with leading zeroes. There are just numbers.
This is very inefficient though, as a string of digit characters takes
up much more memory than a 32bit or even a 64bit int.
How many zeroes were you planning to store? Each one is likely to
require one byte.
Storing as a number still allows for formatting when displaying the
number, correct?
Yes.
I am creating a table and would like opinions regarding this please.


Store numbers as numbers. It's easier to have an opinion when one knows
what you are trying to do and why.

--
--
Lyle

"The aim of those who try to control thought is always the same. They
find one single explanation of the world, one system of thought and
action that will (they believe) cover everything; and then they try to
impose that on all thinking people."
- Gilbert Highet
Nov 13 '05 #5

P: n/a
dkintheuk wrote:
Its possible to argue the case all over the place but experience has
shown me that text for phone numbers always works best.


Well, that settles it. Thanks for the ruling.

--
--
Lyle

"The aim of those who try to control thought is always the same. They
find one single explanation of the world, one system of thought and
action that will (they believe) cover everything; and then they try to
impose that on all thinking people."
- Gilbert Highet
Nov 13 '05 #6

P: n/a
Lyle Fairfield wrote:
sh******@cs.fsu.edu wrote:
I see other posts where some say fields that will hold a number with
leading zeros should be stored as text instead of numbers.

There are no numbers with leading zeroes. There are just numbers.
This is very inefficient though, as a string of digit characters takes
up much more memory than a 32bit or even a 64bit int.

How many zeroes were you planning to store? Each one is likely to
require one byte.
Storing as a number still allows for formatting when displaying the
number, correct?

Yes.
I am creating a table and would like opinions regarding this please.

Store numbers as numbers. It's easier to have an opinion when one knows
what you are trying to do and why.

The day I store SSNs and phone numbers as a numeric field and not as an
alphanumeric field is the day after I retire from programming and
progress to another type of work.
Nov 13 '05 #7

P: n/a

<sh******@cs.fsu.edu> wrote
I see other posts where some say fields
that will hold a number with leading zeros
should be stored as text instead of numbers.

This is very inefficient though, as a string
of digit characters takes up much more
memory than a 32bit or even a 64bit int.

Storing as a number still allows for formatting
when displaying the number, correct?

I am creating a table and would like
opinions regarding this please.


One general rule that seems to work well is to store in numeric field format
if the number is to be used in calculations; store in text if the "number"
is for identification. After a few years in the application development
business, I am no longer surprised when a "Product ID Number" turns out to
have alphabetic characters, or when the client later decides to use
alphabetic characters in a previously all-numeric identification.

Lyle is correct... "leading zeros" are only a particular format for
displaying numbers. 000012 is the same number as 0012 or 12. Rick is
correct... if 000012 is different from 0012 or 12, you are not talking about
numbers, but about numeric characters which you will have to store in text.
Nov 13 '05 #8

P: n/a
Oooo you are cheeky!

Its nice to know that I'm not bonkers after all now i've looked at the
other answers. They also explain it better i.e. calculations use
numeric, idnetifiers use alphanumeric... easy.

Rob.

Nov 13 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.