Posted by Chris Meador on 2000-11-21
> > I'm creating a VB program that calculates numbers for phase. Since the > > program will return negative values as well as positive, I need to > > convert > > negative numbers to positive numbers through basic code so that negative > > values will not appear. > I cant say I know VB, but there will be a command such as 'ABS' which will > convert the given number to a positive number i.e. its absolute value. > Anothelengthy way could be to test if the number is less than 0, and if so > multiply it by -1. I don't know what "phase" refers to either, and I don't know VB. What kind of "numbers"? (integers or reals) I would recommend absolute value to avoid negative numbers, also. If uniqueness is important, though, I would suggest an offset value (equal to the absolute value of the least negative number, e.g. 10 if valid values are -10..5). Then add this offset before returning the value. (The new range in example is 0..15.) Perhaps that was a bad example if you want only positive numbers, but not if avoiding negatives... isn't zero neither? Well, anyway. HTH -- Chris Meador Mississippi State Univ. 904 Suttle Hall (662) 325-6224 Text-page me! 9016343430@xxxxxxx.xxx
Previous post | Next post | Timeline | Home