Jump to content
Sign in to follow this  
daniel02

_Max from <Math.au3> not behaving like expected

Recommended Posts

daniel02

Hi all,

I just wanted to use the _Max. In my opinion the follwoing example should return 0 as the values are the same and there is no higher one. But it returns 11. I think this is a bug... If you do the same with _Min it returns 0.

Or did i get something wrong?

$max= _Max (11, 11)

From Autoit Helpfile

#####################

_Max

--------------------------------------------------------------------------------

Evaluates which of the two numbers is higher.

#include <Math.au3>

_Max ( $nNum1, $nNum2 )

Parameters

$nNum1 First number.

$nNum2 Second number.

Return Value

Success: Returns the higher of the two numbers.

Failure: Returns 0.

@Error: 0 = No error.

1 = $nNum1 isn't a number.

2 = $nNum2 isn't a number.

Remarks

This function works with floats as well as integers.

Share this post


Link to post
Share on other sites
KaFu

Hmmm, both functions return 11 for me.

#include <math.au3>
ConsoleWrite("_max(11,11) = " & _max(11,11) & @crlf)
ConsoleWrite("_min(11,11) = " & _min(11,11) & @crlf)

If you look into the source of math.au3 it's quiet clear why, both functions contain this code

If $nNum1 > $nNum2 Then
        Return $nNum2
    Else
        Return $nNum1
    EndIf

And from a logical standpoint I can't see no bug, as both results are valid imho. What might need a correction is the help-file, as the functions do not return the higher and lower values, but as the function names imply the maximum and minimum value :D...

Edited by KaFu

Share this post


Link to post
Share on other sites
daniel02

If it both returns 11 I agree I have to check again because I think it returns in my script for max the value and for min zero.

If you change of course the helpfile there is no bug :D

But at the moment what I understand from the helpfile is that 0 should return because there is no max vaule if they are the same.

Share this post


Link to post
Share on other sites
PsaltyDS

If it both returns 11 I agree I have to check again because I think it returns in my script for max the value and for min zero.

If you change of course the helpfile there is no bug :o

But at the moment what I understand from the helpfile is that 0 should return because there is no max vaule if they are the same.

That is not the plain meaning of the help file as it stands. Return = 0 only on failure, and @error explains the conditions considered failures:

Return Value

Success: Returns the higher of the two numbers.

Failure: Returns 0.

@Error: 0 = No error.

1 = $nNum1 isn't a number.

2 = $nNum2 isn't a number.

The help file cannot account for every possible poor reading of plain language.

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
KaFu

If it wouldn't have been for the poor speaking part...

If it would return the higher, it should return an error, because there is no higher in _max(11,11)...

_Max

Success: Returns the maximum positive value of the two numbers.

Edited by KaFu

Share this post


Link to post
Share on other sites
youknowwho4eva

Is 11 not the maximum? If you have a set of numbers, and the highest number appears more than once, I think your teacher would slap you if you wrote 0 or error as the answer


Giggity

Share this post


Link to post
Share on other sites
PsaltyDS

If it wouldn't have been for the poor speaking part...

If it would return the higher, it should return an error, because there is no higher in _max(11,11)...

That deserves a Valik-like response that I haven't the skill with vulgarity to pen here.

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
KaFu

Is 11 not the maximum? If you have a set of numbers, and the highest number appears more than once, I think your teacher would slap you if you wrote 0 or error as the answer

In fact, if my teacher would have asked me (in 1st class?) which one is higher, i would've answered none of both...

Success: Returns the higher of the two numbers.

I refer to PsaltyDS's comment for the rest...

PsaltyDS, i've read enough of your posts over the years to highly regard your contribution to Au3 and this forum, but a reply like this

The help file cannot account for every possible poor reading of plain language.

which clearly is NOT true (otherwise Valik would already have kicked in), to a topic on page 2, on which the OP was thoroughly satisfied with, which would already have gone down the road to oblivion by now without your response, is not what I've become to know of you. Enough... Edited by KaFu

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.