Discussion Forums at Tactical Neuronics

Re: Question about the workabiltiy of a piece of code From:

well it wouldnt matter if it was true false or infinite, coz (something)*0 = 0 no matter what.

i think i know what youre trying, i used the same technique for viscerator

ok so your original equation was

cmath v0 = (((~v4 < ~v3)*0+2)OR((~v5 < ~v3)*0+4))OR(((~v6 < ~v3)*0+3)OR((~v7 < ~v3)*0+4))

i believe you wanted to return a 2 if v4 < v3, return a 4 if v5 < v3, return a 3 if v6 < v3, and return a 4 if v7 < v3.

now keep in mind that if either v5 or v7 is less than v3 then v0 will equal 4, is that what you intended?

if so then use:

cmath v0 = -1*(2*(~v4 < ~v3)+3*(~v6 < ~v3)+4*((~v5 < ~v3)OR(~v7 < ~v3)))

now the -1 out the front turns the number into a positive, coz any true/false thingy returns -1 if true, and 0 if false so if v4 was less than v3 than the brackets equal -1 so multiplying that by 2 would give -2, so to make it positive again, you gotta multiply the result by -1.

if more than one bracket is TRUE then the v0 will equal the sum of all the TRUE brackets.

btw ive had a tutorial at http://www.geocities.com/vusak/BugHelp.zip for ages now, it goes into detail about how to use math and how to design a bug, it also has a fully commented example bug to checkout :) (john, you wanna host it in your tutorial section?)


This message is a Reply to: Re: Re: Question about the workabiltiy of a piece of code from jeremiah

Replies to this message:

© 2001, John A. Reder.