From: Rajesh on
Hi,

How can i convert the following string into the same number

'001'(string) converted to 001 (number)

str2num or str2double eats the leading zeros. any suggestions??

thanks.
From: Andy on
"Rajesh " <rv_acharya(a)rediffmail.com> wrote in message <i40o3d$s48$1(a)fred.mathworks.com>...
> Hi,
>
> How can i convert the following string into the same number
>
> '001'(string) converted to 001 (number)
>
> str2num or str2double eats the leading zeros. any suggestions??
>
> thanks.

What? Numbers don't have leading zeros. Formatted strings representing numbers can have leading zeros. Keep your numbers as numbers until you need to format them for output. Then use sprintf to add your leading zeros back in if you must.
From: Walter Roberson on
Rajesh wrote:

> How can i convert the following string into the same number
>
> '001'(string) converted to 001 (number)
>
> str2num or str2double eats the leading zeros. any suggestions??

Is 0/00 different than 00/0 ?
From: Walter Roberson on
Andy wrote:
> "Rajesh " <rv_acharya(a)rediffmail.com> wrote in message
> <i40o3d$s48$1(a)fred.mathworks.com>...

>> How can i convert the following string into the same number
>>
>> '001'(string) converted to 001 (number)
>>
>> str2num or str2double eats the leading zeros. any suggestions??

> What? Numbers don't have leading zeros. Formatted strings representing
> numbers can have leading zeros.

'0' is a _numeral_ . _numbers_ are mathematical quantities independent of
numerals that may be used to denote them. Numbers do not have leading numerals
or trailing numerals or _any_ numerals: they just *are*.


Let's see if I remember my Incomplete Enchanter correctly:

"A number is a class of all classes that are similar to themselves."

Hmmm, doesn't quite look right, but I don't have my reference handy.
From: Matt Fig on
Walter Roberson <roberson(a)hushmail.com> wrote in message
> Let's see if I remember my Incomplete Enchanter correctly:
>
> "A number is a class of all classes that are similar to themselves."
>
> Hmmm, doesn't quite look right, but I don't have my reference handy.


How about:

Numbers are necessary objects. By necessary we mean that the question, "Why do numbers exist?" cannot sensibly be asked.
Kinda like: Why are vacuums empty?