Modify

#2322 closed Feature Request (Rejected)

Random() produces unexpected result.

Reported by: autoit@… Owned by:
Milestone: Component: AutoIt
Version: Severity: None
Keywords: Cc:

Description

If the MIN and MAX values are the same number, the result should be that number. Instead, Random() returns 0.

$foo = Random(1, 1, 1)
ConsoleWrite(".\" & @ScriptName & " (" & @ScriptLineNumber & ") : ==> " & "foo: " & $foo & @LF)

#cs
---------- RUN ----------
.\test.au3 (12) : ==> foo: 0

Output completed (0 sec consumed) - Normal Termination
#ce

Random(5, 5) also returns 0.

Attachments (0)

Change History (7)

comment:1 by guinness, on Mar 3, 2013 at 5:49:34 PM

This is documented in the beta version of the help file that if the values are the same it returns 0 and sets @error to 1. So I can't see how it could be a bug but I will leave it for a developer to decide on whether this ticket is valid.

comment:2 by jchd, on Mar 3, 2013 at 11:33:48 PM

This strongly counter-intuitive behavior is by design decision and has been questionned really many times before. A simple search would have found tickets 1538, 1251, 1170, 573 and 296, all of them closed under "no bug" tag.

While I consider the current behavior to be a terrible misconception I'm not in the position to change devs mind(s) on it. This ticket should now be a feature request.

comment:3 by Cor <autoit@…>, on Mar 4, 2013 at 2:04:21 AM

A simple search revealed nothing. Thanks anyway. Feel free to file under a feature request, though simply stating the expected output in the current help file would be sufficient. It's trivial to work around once you know what's happening.

comment:4 by jchd, on Mar 4, 2013 at 11:31:39 AM

Trac tickets can be searched and this what I was pointing out. Besides, this section is for posting confirmed bugs after inquiring on the help forum. BTW, simple search there on "random bug" lists several clearly relevant threads like this recent one.

Next time please post such question in the general help forum before overloading this section which is not for discussion.

Thanks.

comment:5 by guinness, on Mar 4, 2013 at 10:37:26 PM

Type: BugFeature Request

comment:6 by TicketCleanup, on Mar 4, 2013 at 11:00:01 PM

Version: 3.3.8.1

Automatic ticket cleanup.

comment:7 by Jon, on Jul 21, 2013 at 11:32:31 PM

Resolution: Rejected
Status: newclosed

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.