Have I closed correctly...
-
Hi All, I asked a bit of an odd question on Friday about converting an integer to a string, using CP more as a rubber duck.. got caught with something else that went pop (real smoke!) and could give much attention to it. Came in this morning late (as I had to get the bus replacement, for the bus replacement for the rail replacement, don't ask!) to find the main job for today had been shelved due to non-delivery of parts. So I could get back to programming the widget I am working on and bingo! Now I need to close it... so it's not waiting...
First, you have to be respectful of the integer's parents and talk to them about conversion. Then you need to take the integer to church every Sunday so they can talk to the stringy pastor. Most importantly, you cannot force it to convert. It has to be authentic and natural. But, if the integer hangs around enough strings, perhaps one day it'll see the light and realize a character representation of numbers that requires encoding is a much better means of representing data than a number that requires interpretation.
Jeremy Falcon
-
First, you have to be respectful of the integer's parents and talk to them about conversion. Then you need to take the integer to church every Sunday so they can talk to the stringy pastor. Most importantly, you cannot force it to convert. It has to be authentic and natural. But, if the integer hangs around enough strings, perhaps one day it'll see the light and realize a character representation of numbers that requires encoding is a much better means of representing data than a number that requires interpretation.
Jeremy Falcon
So that's where I've been going wrong! if integers go to see the stringy pastor, do floats just float around?
-
Hi All, I asked a bit of an odd question on Friday about converting an integer to a string, using CP more as a rubber duck.. got caught with something else that went pop (real smoke!) and could give much attention to it. Came in this morning late (as I had to get the bus replacement, for the bus replacement for the rail replacement, don't ask!) to find the main job for today had been shelved due to non-delivery of parts. So I could get back to programming the widget I am working on and bingo! Now I need to close it... so it's not waiting...
string num = "-5498";
int pos = 0;
int result = 0;
int len = num.Length;
bool neg = false;
if(num[0]=='-') { ++pos; neg = true; }
while(possomething like that?
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix -
So that's where I've been going wrong! if integers go to see the stringy pastor, do floats just float around?
Floats should go too, but they're stubborn so you'd have to double down. :-\
Jeremy Falcon
-
string num = "-5498";
int pos = 0;
int result = 0;
int len = num.Length;
bool neg = false;
if(num[0]=='-') { ++pos; neg = true; }
while(possomething like that?
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uixNothing nearly that bomb proof, itoa(), as it a value from a sensor reality has issues if it's negative! (mind you checking to see if it's negative might be an idea... sensor can kick out negative if calibrates wrongly!)
-
Nothing nearly that bomb proof, itoa(), as it a value from a sensor reality has issues if it's negative! (mind you checking to see if it's negative might be an idea... sensor can kick out negative if calibrates wrongly!)
To be fair, i can break what i wrote by feeding it non-numeric characters. I would say more quick and dirty than bomb proof. itoa() works, but it doesn't stream, which is why I've written the above code more times than i care to admit!
Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix
-
Floats should go too, but they're stubborn so you'd have to double down. :-\
Jeremy Falcon
And your point is?
Software Zen:
delete this;
-
And your point is?
Software Zen:
delete this;
One can mantissapate that response. :rolleyes:
Jeremy Falcon
-
One can mantissapate that response. :rolleyes:
Jeremy Falcon
-
One can mantissapate that response. :rolleyes:
Jeremy Falcon
Better than mansplaining it, I guess.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
-
string num = "-5498";
int pos = 0;
int result = 0;
int len = num.Length;
bool neg = false;
if(num[0]=='-') { ++pos; neg = true; }
while(possomething like that?
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix -
OP says "integer to a string". Did I misread something in that or your code? And C# already has that for both directions.
No, I misread something in the OP. :laugh: Int to string is even easier. Edit: C# can't stream to an arbitrary length integer off a textreader for example. That's why I've had to write the parsing code myself.
Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix