Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ Programming
➜ General
➜ Help with a numbers solution
Help with a numbers solution
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Daniel Spain
(15 posts) Bio
|
Date
| Thu 03 May 2012 07:09 PM (UTC) |
Message
| 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? | Top |
|
Posted by
| Fiendish
USA (2,535 posts) Bio
Global Moderator |
Date
| Reply #1 on Fri 04 May 2012 03:39 AM (UTC) |
Message
|
Quote: atoi(ltoa(...))
What was the point of this?
|
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Daniel Spain
(15 posts) Bio
|
Date
| Reply #2 on Fri 04 May 2012 08:39 AM (UTC) |
Message
|
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.
| Top |
|
Posted by
| Fiendish
USA (2,535 posts) Bio
Global Moderator |
Date
| Reply #3 on Sat 05 May 2012 12:59 AM (UTC) 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. |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #4 on Sat 05 May 2012 08:18 AM (UTC) |
Message
| 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. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Fiendish
USA (2,535 posts) Bio
Global Moderator |
Date
| Reply #5 on Sat 05 May 2012 02:03 PM (UTC) Amended on Sat 05 May 2012 02:07 PM (UTC) by Fiendish
|
Message
|
Twisol said:
It converts from a long to an int, stopping over in stringland in between. It then casts back to long. It's all kind of silly. In a 32 bit environment int and long are the same thing anyway in C. |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #6 on Sun 06 May 2012 12:54 AM (UTC) |
Message
| 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. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
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.
22,155 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top