# is there a method to filter positive and negative low numbers

All activity at MQL5.community is clearly visible. Have a look at the Wall!
78
2015.10.14 05:08

i am dealing with very low values, like: 0.0000001 vs -0.0000001.

in comparison with zero the compiler seems to be confused.

is there any way to detect precisely (and not by comparison with zero) - which number is positive and negative.

regards

1385
2015.10.14 12:00
Calin Trainer:

i am dealing with very low values, like: 0.0000001 vs -0.0000001.

in comparison with zero the compiler seems to be confused.

is there any way to detect precisely (and not by comparison with zero) - which number is positive and negative.

regards

I believe this must work ...

if your number is a, define it a as double, Not Integer (int).

then,

```string result = "Neutral";

if(a>0)
result = "Positive";

if(a<0)
result = "Negative";

```
Moderator
4505
2015.10.14 12:31
he said, and not by comparison with zero.
5718
2015.10.14 12:37
You could try normalizing it on say a 0 to 100 scale, then comparing to the medium value ( in this case 50)
601
2015.10.14 13:08

You can also try to use a string value to detect the negative numbers and use the "-" negative sign symbol for detection.

For example, this code uses the StringSubstr(); function to select the first symbol in the string and uses it for a reference.

```double dMyAlmostZeroValue = 0;

{

dMyAlmostZeroValue = -0.0000001;
}

string sTextValue = dMyAlmostZeroValue;
sTextValue  = StringSubstr(sTextValue , 0, 1); // First symbol in the string.

if(sTextValue == "-" )
{
}

```
601
2015.10.14 15:30

Your quote is: "in comparison with zero the compiler seems to be confused"

A "double" type variable has 15 significant digits. The compiler should be able to detect if a very small number (close to zero) is positive or negative.

-0.0000001 has only 7 digits.

https://www.mql5.com/en/docs/basis/types/double

Which variable type do you use?

Documentation on MQL5: Language Basics / Data Types / Real Types (double, float)
• www.mql5.com
Language Basics / Data Types / Real Types (double, float) - Reference on algorithmic/automated trading language for MetaTrader 5
78
2015.10.14 16:10

i have them defined as doubles.

i like the idea with string (-) detection... but, really ?!!?!

78
2015.10.14 16:13
snelle_moda:

Your quote is: "in comparison with zero the compiler seems to be confused"

A "double" type variable has 15 significant digits. The compiler should be able to detect if a very small number (close to zero) is positive or negative.

-0.0000001 has only 7 digits.

https://www.mql5.com/en/docs/basis/types/double

Which variable type do you use?

you seem to have had a tough confrontation with this issue before (correct?)... two posts with two good ideas.

i have them as doubles and they are not recognized vs 0 comparison.

thank you sir.

601
2015.10.14 16:39

A different simple solution is multiply your small number with a large number.

Then the number of digits is smaller.

For example

-0.0000001 X 1.000.000 = -0.1

Now you can compare this number with zero as mentioned in the second post.

78
2015.10.14 18:34
snelle_moda:

A different simple solution is multiply your small number with a large number.

Then the number of digits is smaller.

For example

-0.0000001 X 1.000.000 = -0.1

Now you can compare this number with zero as mentioned in the second post.

that i done. not sure if works well...

it is smthing like: if (MAArray[1]*1000000 >0){bla}

Moderator
30295
2015.10.15 08:44
Calin Trainer:

you seem to have had a tough confrontation with this issue before (correct?)... two posts with two good ideas.

i have them as doubles and they are not recognized vs 0 comparison.

thank you sir.

Fix your code. The compiler doesn't have any problem with positive/negative number, all these "solutions" are useless.
/ /12