|
The one I like is; Dogs have owners cats have staff.
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
|
|
|
|
|
I hadn't heard that one but applies.
"Ten men in the country could buy the world and ten million canβt buy enough to eat." Will Rogers
PartsBin an Electronics Part Organizer - Release Version 1.3.0 JaxCoder.com
Latest Article: EventAggregator
|
|
|
|
|
Cats have clients, who pay for the privilege.
Software Zen: delete this;
|
|
|
|
|
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
modified 22-Jan-24 16:25pm.
|
|
|
|
|
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
modified 22-Jan-24 15:42pm.
|
|
|
|
|
And your point is?
Software Zen: delete this;
|
|
|
|
|
One can mantissapate that response.
Jeremy Falcon
|
|
|
|
|
groan
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
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(pos<len) {
result*=10;
result = (int)(num[pos]-'0');
++pos;
}
if(neg) result = -1 * result;
something 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
|
|
|
|
|
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!)
modified 22-Jan-24 15:45pm.
|
|
|
|
|
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
|
|
|
|
|
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.
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
|
|
|
|
|
Wordle 947 5/6
π¨β¬β¬β¬β¬
β¬β¬π¨β¬π¨
β¬π¨β¬π¨β¬
β¬β¬π©π©π¨
π©π©π©π©π©
|
|
|
|
|
Wordle 947 4/6*
π¨β¬β¬β¬π¨
β¬π¨π¨β¬π¨
π©π¨π¨π¨β¬
π©π©π©π©π©
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Wordle 947 3/6
π©β¬π¨β¬π¨
π©π¨π¨π¨β¬
π©π©π©π©π©
|
|
|
|
|
Wordle 947 4/6*
β¬β¬π¨π¨π¨
β¬β¬π©π©π¨
π©β¬π©π©β¬
π©π©π©π©π©
Happiness will never come to those who fail to appreciate what they already have. -Anon
And those who were seen dancing were thought to be insane by those who could not hear the music. -Frederick Nietzsche
|
|
|
|
|
β¬β¬π¨β¬π¨
β¬β¬β¬β¬β¬
β¬β¬π©π©π¨
π©π©π©π©π©
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
|
|
|
|
|
Wordle 947 6/6
β¬β¬β¬β¬β¬
β¬β¬π©β¬β¬
β¬β¬π¨π¨π¨
β¬π¨π¨π©β¬
β¬π¨π©π©π©
π©π©π©π©π©
Phew.
|
|
|
|
|
Wordle 947 4/6
π¨β¬β¬β¬π¨
β¬β¬π©π©β¬
β¬π¨π©π©β¬
π©π©π©π©π©
Ok, I have had my coffee, so you can all come out now!
|
|
|
|
|
Wordle 947 4/6
π¨β¬β¬π¨β¬
β¬β¬π©π©π©
β¬π¨π©π©π©
π©π©π©π©π©
|
|
|
|
|
Wordle 947 3/6
β¬π¨π¨β¬π¨
β¬π¨π©π©β¬
π©π©π©π©π©
Jeremy Falcon
|
|
|
|