Author Topic: Questions on Ceil and Floor  (Read 9896 times)

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Questions on Ceil and Floor
« Reply #15 on: March 11, 2005, 08:38:07 PM »
Num, why fix a bug by adding code when you can fix it by changing code? I believe there is a bug in the vb code you posted. I also believe there is no bug in the code I posted.

The problem is I dont have the rest of your code , thats why I cant pinpoint were the bug is.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Questions on Ceil and Floor
« Reply #16 on: March 11, 2005, 08:47:23 PM »
How can there be a bug?

'This one could be very useful
Private Sub DNASgn(robotnumber As Integer) 'returns sign of number on stack
    Dim a As Integer
    a = readst(robotnumber)
   
    writest robotnumber, Sgn(a)
End Sub

"readst" reads the top number of the stack from robotnumber.

"writest" writes a number to the stack of robotnumber.

So where's the bug?  How can there be a bug?  And last, why try to figure it out when you can just add:

if a = 0 then
writest robotnumber, 0
else
writest robotnumber, sgn(a)
end if

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Questions on Ceil and Floor
« Reply #17 on: March 11, 2005, 09:08:41 PM »
There is a bug in
"readst" reads the top number of the stack from robotnumber.
or
"writest" writes a number to the stack of robotnumber.

Paste the code for thouse custom  functions, paste the code for the stack itself, Paste the code for all the custom functions used by thouse custom functions, And I will show you were the bug is trust me!

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Questions on Ceil and Floor
« Reply #18 on: March 11, 2005, 09:31:31 PM »
A magical bug that only manifests itself in the DNAsgn function, huh?  A bug that has gone magically unnoticed since DB 1.0 was released?

Okay, sarcasm aside, it's not a bug.  I'll post the DNA parsing module so you can look it over if you like, but you're not going to find anything.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Questions on Ceil and Floor
« Reply #19 on: March 11, 2005, 09:46:51 PM »
'boolstack structure used for conditionals
Private Type boolstack
  val(20) As Boolean
  pos As Integer
End Type
Private Const stacklim As Integer = 20
Dim currgene As Long 'for *.thisgene
Dim Condst As boolstack 'for the conditions stack
'/*********I had to gess this
Private Type stackishere
pos As Double
val(255) As Double
End Type
Private Type therobotsarehere
st As stackishere
End Type
Dim rob(20) As therobotsarehere
'\**************

Private Sub DNASgn(robotnumber As Integer) 'returns sign of number on stack
Dim a As Integer
a = readst(robotnumber)

writest robotnumber, Sgn(a)
End Sub

Private Function readst(n As Integer) As Integer
  readst = 0
  If rob(n).st.pos > 0 Then
    readst = rob(n).st.val(rob(n).st.pos)
    rob(n).st.pos = rob(n).st.pos - 1
  End If
End Function

' stack push
Private Sub writest(n As Integer, val)
  If Abs(val) > 32000 Then val = Sgn(val) * 32000
  If rob(n).st.pos < stacklim Then
    rob(n).st.pos = rob(n).st.pos + 1
    rob(n).st.val(rob(n).st.pos) = val
  End If
End Sub

Private Sub Form_Load()
writest 0, 700
DNASgn 0
MsgBox rob(0).st.val(rob(n).st.pos) ' returns 1
'
writest 0, 0
DNASgn 0
MsgBox rob(0).st.val(rob(n).st.pos) ' returns 0
'
writest 0, -700
DNASgn 0
MsgBox rob(0).st.val(rob(n).st.pos) ' returns -1
End Sub
'Even In your own code It returns 0 for 0, rofl , now what?

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Questions on Ceil and Floor
« Reply #20 on: March 11, 2005, 09:56:12 PM »
Hey, you're the one finding 'bugs', not me.  If according to your tests no bugs exist, then problem solved!

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Questions on Ceil and Floor
« Reply #21 on: March 11, 2005, 10:03:31 PM »
yea but my output is "1; 0; -1" <---------

its not: "1; 1; -1" right?

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Questions on Ceil and Floor
« Reply #22 on: March 11, 2005, 10:12:20 PM »
Again, I don't see the problem.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Questions on Ceil and Floor
« Reply #23 on: March 11, 2005, 10:19:12 PM »
if a = 0 then
writest robotnumber, 0
else
writest robotnumber, sgn(a)
end if

The above code is not required because sgn does it automaticaly.
I dont know were Endy, Py, and YOU got the "1 1 -1" from...
« Last Edit: March 11, 2005, 10:23:29 PM by Botsareus »

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Questions on Ceil and Floor
« Reply #24 on: March 11, 2005, 10:36:18 PM »
The sign of zero.

Basically anything we choose, 1, -1, or 0, are all ligitimate choices for the sign of zero.

Don't know where I got the sign on 0 as 1 from.  Just figured that sgn only returns two values.
« Last Edit: March 11, 2005, 10:37:17 PM by Numsgil »

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Questions on Ceil and Floor
« Reply #25 on: March 12, 2005, 11:16:30 AM »
So whats going on with DB and Endy , what is he complaining about?

(I bet there is a bug somewere that returns the beepin "1 1 -1" , its just not in the code you gave me Num)

(Endy help me out here , the bug still happens?)
« Last Edit: March 12, 2005, 11:18:00 AM by Botsareus »

Offline Endy

  • Bot Overlord
  • ****
  • Posts: 852
    • View Profile
Questions on Ceil and Floor
« Reply #26 on: March 13, 2005, 12:12:28 AM »
I think Nums is saying he fixed it. Not real sure would have to see new 3.16Beta vers to check.

Endy B)