flux Posted September 21, 2018 Share Posted September 21, 2018 (edited) I seem to be getting incorrect results when I'm adding two variables together. I'll call them A and B for example. If A=178 and B=296, the answer I get when I add them and store the answer in variable 'C' and print that variable to the screen is 47495680. The first three digits are the correct answer, and no matter what values I set A and B to, the first digits will always be accurate. But it seems to be appending a bunch of digits or multiplying it by some hundred odd thousand or so. There's no other code changing these variables between the time they're set and when they get printed to the screen. Am I running out of memory or reaching some other kind of limitation? Everything seemed to be going well previously... Edit: Disregard. I think I figured it out. But there's no way to delete a post here? Even if it has no replies? Edited September 21, 2018 by flux Quote Link to comment Share on other sites More sharing options...
saboteur Posted September 21, 2018 Share Posted September 21, 2018 Out of interest Flux ( and for the sake of completeness ), what was the answer ? It's always good to know, especialy if someone else has a similar problem. Cheers Quote Link to comment Share on other sites More sharing options...
ggn Posted September 21, 2018 Share Posted September 21, 2018 Well, if you posted this on the rb+ forum (where I'm a moderator) I'd have zapped it for you. No luck here . Quote Link to comment Share on other sites More sharing options...
Zerosquare Posted September 21, 2018 Share Posted September 21, 2018 So, let me guess: you always print the result at the same position, and the extra digits you were seeing were remains of previous prints. Solution: clear the screen, or add a bunch of spaces after the number Quote Link to comment Share on other sites More sharing options...
flux Posted September 21, 2018 Author Share Posted September 21, 2018 It was more a case of I didn't describe the situation accurately and I'm embarrassed to admit I didn't catch it before I posted. At the time, it was so inexplicable that I had no idea what to do. Turns out, I had the wrong variable assignment statement commented out and one of the variables was indeed changing, and at a pretty rapid pace. I didn't look into it enough to investigate why it kept the correct digits at the front. It seems like it ought to have been more random than that but I was just happy to get rid of that whole thing. However, and maybe this isn't the best spot for this and I should start a new thread. There does seem to be some other unrelated weirdness I can't seem to get straightened out. I have a couple of variables for my sprite's x and y coordinates, and sometimes I will print those values to the screen when such information is useful. The problem is that half the time, the numbers seem to jump all over the place. My x coordinate will jump from 100 something to 600 (well outside of the area for the resolution I'm at) and then maybe back down to something else and then at some point return to something expected and normal. The weird bit is, as near as I can tell, my sprite isn't jumping around accordingly. It just keeps moving smoothly and steadily around the screen. I haven't worried about it too much yet since it doesn't seem to actually break anything. I'm sure I'm doing something wrong and I'll figure it out eventually, but does that sound familiar to anyone? On a related note, is there a way to look up and return the current properties of an object such as its coordinates or flip status or scale value or is the only way to do it is manually track that stuff with variables? 1 Quote Link to comment Share on other sites More sharing options...
ggn Posted September 21, 2018 Share Posted September 21, 2018 However, and maybe this isn't the best spot for this and I should start a new thread. Yes, please open a thread in rb+ so we won't bore people to death here Quote Link to comment Share on other sites More sharing options...
LinkoVitch Posted September 24, 2018 Share Posted September 24, 2018 Flux it sounds like you have fallen foul of solving bugs the way I have done many times You hit a bug, it makes no sense, you try to figure it out, get no where, so you grab a nearby colleague (in this case the forum) and explain the problem to them, except that as you are explaining the solution presents itself and you realise what you did wrong, quite often they don't even get the full detail of the issue. (or there about) I recommend you get yourself some teddy bears, or rubber ducks, (or some other inanimate object), when you hit a problem like this, try explaining it to one of the ducks/bears/etc.. whilst they'll not say anything, can cause you to find something you had previously overlooked... can be good to have a few in case the 1st couple don't yield results.. Then there is always the forums when this doesn't work (except GGN/Zero will occasionally quack ) 5 Quote Link to comment Share on other sites More sharing options...
swapd0 Posted September 24, 2018 Share Posted September 24, 2018 https://en.wikipedia.org/wiki/Rubber_duck_debugging 3 Quote Link to comment Share on other sites More sharing options...
Zerosquare Posted September 24, 2018 Share Posted September 24, 2018 I must say that's the first time I'm compared to a rubber duck 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.