Right, but the int -> long conversion is lossless. Good point about int and long in a 32-bit environment. Since it's probably a safe bet that this was written for a 32-bit computer, I'd say it's totally safe to remove.
It converts from a long to an int, stopping over in stringland in between. I don't think there's any harm in removing it, though you might want to find out how itoa handles values that are out-of-range. A simple cast might behave differently.
Amended on Sat 05 May 2012 01:02 AM (UTC) by Fiendish
Message
Daniel Spain said:
Fiendish said:
Quote: atoi(ltoa(...))
What was the point of this?
well when i got the codebase it was already a completed game, written in bcc 3.1 i finalized it and ported it to bcc 4.5 then bbsing went dormant we all moved on to other things well i picked it back up a few years ago and ported it to bcc 5.01 then to 5.5.1 and never had to touch most the code except maybe make a few changes just to get rid of annoying compiler warnings but with making it standalone i hit alot of errors just on things like the above code which is why i asked. i am no career developer by far all my knowledge has came from trial and error on this same codebase since the mid 90's and well since it worked won;t no need in fixing it and this porting project broke it so i had to fix it.
I meant very specifically what is the point of taking a number, converting it to a string, and then converting the string back to a number? :)
Like 5->"5"->5
It looks to me like the original way had no value so you didn't lose anything by removing it.
well when i got the codebase it was already a completed game, written in bcc 3.1 i finalized it and ported it to bcc 4.5 then bbsing went dormant we all moved on to other things well i picked it back up a few years ago and ported it to bcc 5.01 then to 5.5.1 and never had to touch most the code except maybe make a few changes just to get rid of annoying compiler warnings but with making it standalone i hit alot of errors just on things like the above code which is why i asked. i am no career developer by far all my knowledge has came from trial and error on this same codebase since the mid 90's and well since it worked won;t no need in fixing it and this porting project broke it so i had to fix it.
hello all back in the 90's using bcc 3.1 i wrote a mud for a bbs software and here recently i have been porting it to a standalone using Nick's barebones mud server.
i hit a compile error with this math function.
long ep2 = atoi(ltoa(((p->exp/(DEFEPL+axp))+1)));
to fix the compile error i adjusted it like so:
long ep2 = ((p->exp/(DEFEPL+axp))+1);
will this suffice or could i lose any of the value in the conversion?
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.