Hi,

If the size of the integer isn't an issue... maybe just concatenate the
values together... only problem is if you use ascii to decimal A starts at
65 and z ends at 122... so you’d have to use padding up to 100 to keep all
the values the same length... but if you use the Octal values A starts a 101
and z end at 172.



abcd = %141%142%143%144 = 141142143144


On 11 October 2011 07:24, Tom Gao <t...@tomgao.com> wrote:

> Yep true I realised that… it was my fault I wasn’t specific enough with my
> question. I didn’t realise it until I saw the algorithm.****
>
> ** **
>
> Still many thanks David it looked good J****
>
> ** **
>
> Can anyone think of a way to do this that will allow me to convert the int
> back to string. I don’t have a problem with length luckily .net 4.0 comes
> with arbitrary precision which allows 2trillion digits (slow as hell
> compared to c++ arbitrary precision). But just need a way back from int back
> to str****
>
> ** **
>
> *From:* ozdotnet-boun...@ozdotnet.com [mailto:
> ozdotnet-boun...@ozdotnet.com] *On Behalf Of *noonie
> *Sent:* Tuesday, 11 October 2011 8:13 AM
>
> *To:* ozDotNet
> *Subject:* Re: ASCII to int****
>
> ** **
>
> Tom,****
>
> ** **
>
> Using David's method will turn a string to an int. But there are two
> problems.****
>
> ** **
>
> 1. If the string is very long then it will overflow int. ****
>
> 2. You can't turn it back to the same string you started with.****
>
> ** **
>
> --
> noonie****
>
> On 11 October 2011 08:09, Tom Gao <t...@tomgao.com> wrote:****
>
> sorry there’s no real world scenario for this. I’m trying to replicate some
> calculation purely for academic reasons.****
>
>  ****
>
> *From:* ozdotnet-boun...@ozdotnet.com [mailto:
> ozdotnet-boun...@ozdotnet.com] *On Behalf Of *David Kean
> *Sent:* Tuesday, 11 October 2011 7:42 AM****
>
>
> *To:* ozDotNet
> *Subject:* RE: ASCII to int****
>
>  ****
>
> Can I ask what’s the scenario?  ****
>
>  ****
>
> *From:* ozdotnet-boun...@ozdotnet.com
> [mailto:ozdotnet-boun...@ozdotnet.com] *On Behalf Of *Tom Gao
> *Sent:* Monday, October 10, 2011 1:36 PM
> *To:* 'ozDotNet'
> *Subject:* RE: ASCII to int****
>
>  ****
>
> Very nice. Thank you****
>
>  ****
>
> Any suggestion on how I can convert it back to string?****
>
>  ****
>
>  ****
>
> *From:* ozdotnet-boun...@ozdotnet.com
> [mailto:ozdotnet-boun...@ozdotnet.com] *On Behalf Of *David Rhys Jones
> *Sent:* Tuesday, 11 October 2011 1:05 AM
> *To:* ozDotNet
> *Subject:* Re: ASCII to int****
>
>  ****
>
>             int total = 0;
>             string str = "abcdefghijklmnopqrstuvwxyz";
>             foreach (char c in str.ToCharArray())
>             {
>                 total += (int)c;
>             }
>
>             Assert.AreEqual(42, total);
>
>
> ****
>
> Davy,
>
>
> "Always code as if the guy who ends up maintaining your code will be a
> violent psychopath who knows where you live." ****
>
> - Martin Golding
>
> "After a bit of digging, it was pretty clear that the 'issues' were in the
> data access class. It was named 'summoner.cs'"  DailyWTF****
>
>  ****
>
> On Mon, Oct 10, 2011 at 3:37 PM, Tom Gao <t...@tomgao.com> wrote:****
>
> Hi All,****
>
>  ****
>
> Does anyone know how to convert a string of ASCII characters to int? ****
>
> Eg****
>
> “abcd” to some form of int.****
>
>  ****
>
> I need to do a bunch of calculations on strings the only way is if they’re
> in int not sure if anyone know of a good way to do this.****
>
>  ****
>
> Thanks,****
>
> Tom****
>
>  ****
>
> ** **
>



-- 
Cheers,
Shane

DISCLAIMER NOTICE
The contents of this email are confidential.  If you are not the intended
recipient, you must not disclose, copy or use the contents in anyway.  If
you have received this email in error, please delete it and notify us by
reply email.  It is the recipient's responsibility to screen this message
and any attachments for computer viruses.
Thank you.

Reply via email to