Author Topic: Maths division returning -3  (Read 1444 times)

0 Members and 1 Guest are viewing this topic.

Offline JSRNerdo

  • [`_`]/
  • 29
  • Gone!
Maths division returning -3
Hello. I'm trying to divide a variable by 50, then feed that into a modify-variable, to make that the value of another variable. However, when I do this, it always returns -3 for some reason. I'm not sure what's going on or why maths doesn't work. To be honest, even using maths is pretty much a hack for fire-beam burst fire beams, but hey, that's fredding.

Anyway, the relevant sexp test:

   ( modify-variable
      @LeftBeamTick[0]
         ( / ( - @BeamLeftStatus[200] 150 ) 50 )
   )

BeamLeftStatus always has to be above 200 for this event to fire, so that shouldn't be the problem. I've also tested without the subtraction, still returns -3.

Any ideas?
Former Inferno lead, BTA fredder-ish and DE fredder. Driven out by ordinary fascists the_e, aesaar and general battuta. Will return if they're ever removed.

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Maths division returning -3
FRED only thinks in integers, could that be the problem?

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Maths division returning -3
What does the event log output?


Also, try putting in P=NP. A Nobel prize awaits. :p
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline JSRNerdo

  • [`_`]/
  • 29
  • Gone!
Re: Maths division returning -3
Oh.

I'm an idiot.

Found the problem, I had modified the variable BeamLeftStatus to 0 BEFORE dividing, not after. After swapping the orders of the sexps, it works as intended.
Former Inferno lead, BTA fredder-ish and DE fredder. Driven out by ordinary fascists the_e, aesaar and general battuta. Will return if they're ever removed.

 

Offline AdmiralRalwood

  • 211
  • The Cthulhu programmer himself!
    • Skype
    • Steam
    • Twitter
Re: Maths division returning -3
Found the problem, I had modified the variable BeamLeftStatus to 0 BEFORE dividing, not after. After swapping the orders of the sexps, it works as intended.
...:wtf: But...
I've also tested without the subtraction, still returns -3.
:confused:
Ph'nglui mglw'nafh Codethulhu GitHub wgah'nagl fhtagn.

schrödinbug (noun) - a bug that manifests itself in running software after a programmer notices that the code should never have worked in the first place.

When you gaze long into BMPMAN, BMPMAN also gazes into you.

"I am one of the best FREDders on Earth" -General Battuta

<Aesaar> literary criticism is vladimir putin

<MageKing17> "There's probably a reason the code is the way it is" is a very dangerous line of thought. :P
<MageKing17> Because the "reason" often turns out to be "nobody noticed it was wrong".
(the very next day)
<MageKing17> this ****ing code did it to me again
<MageKing17> "That doesn't really make sense to me, but I'll assume it was being done for a reason."
<MageKing17> **** ME
<MageKing17> THE REASON IS PEOPLE ARE STUPID
<MageKing17> ESPECIALLY ME

<MageKing17> God damn, I do not understand how this is breaking.
<MageKing17> Everything points to "this should work fine", and yet it's clearly not working.
<MjnMixael> 2 hours later... "God damn, how did this ever work at all?!"
(...)
<MageKing17> so
<MageKing17> more than two hours
<MageKing17> but once again we have reached the inevitable conclusion
<MageKing17> How did this code ever work in the first place!?

<@The_E> Welcome to OpenGL, where standards compliance is optional, and error reporting inconsistent

<MageKing17> It was all working perfectly until I actually tried it on an actual mission.

<IronWorks> I am useful for FSO stuff again. This is a red-letter day!
* z64555 erases "Thursday" and rewrites it in red ink

<MageKing17> TIL the entire homing code is held up by shoestrings and duct tape, basically.

 

Offline 0rph3u5

  • 211
  • Oceans rise. Empires fall.
Re: Maths division returning -3
Found the problem, I had modified the variable BeamLeftStatus to 0 BEFORE dividing, not after. After swapping the orders of the sexps, it works as intended.
...:wtf: But...
I've also tested without the subtraction, still returns -3.
:confused:

He was going for ( 200 - 150 ) / 50 = 3  due to the error he had ( 0 - 150 ) / 50 = -3
as for the without substaction part I am as puzzled as you are... (I am also quite tired and may or may not have access to my full visual field at the moment...)
« Last Edit: July 25, 2016, 03:26:14 pm by 0rph3u5 »
"As you sought to steal a kingdom for yourself, so must you do again, a thousand times over. For a theft, a true theft, must be practiced to be earned." - The terms of Nyrissa's curse, Pathfinder: Kingmaker

==================

"I am Curiosity, and I've always wondered what would become of you, here at the end of the world." - The Guide/The Curious Other, Othercide

"When you work with water, you have to know and respect it. When you labour to subdue it, you have to understand that one day it may rise up and turn all your labours into nothing. For what is water, which seeks to make all things level, which has no taste or colour of its own, but a liquid form of Nothing?" - Graham Swift, Waterland

"...because they are not Dragons."