Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
General
»
randomrange
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
[SOLVED] Lazreport Horizo...
by
Petrus Vorster
[
Today
at 08:03:05 am]
We are starting to use La...
by
ALLIGATOR
[
Today
at 05:19:46 am]
The Future of FPC
by
ALLIGATOR
[
Today
at 05:01:20 am]
ThorVG - test (lightweigh...
by
ALLIGATOR
[
Today
at 04:55:46 am]
fpGUI Toolkit v2.0.1 has ...
by
cdbc
[
Today
at 02:27:42 am]
[ANN] fpGUI Toolkit v2.0....
by
Graeme
[
Today
at 01:43:31 am]
Frustrating Error When us...
by
TYDQ
[
Today
at 01:38:26 am]
Fast Canvas Library V1.05...
by
backprop
[
Today
at 01:32:51 am]
; after then
by
Martin_fr
[
Today
at 12:38:46 am]
Are the source files for ...
by
Martin_fr
[
Today
at 12:26:57 am]
Debian removes FPC/Lazaru...
by
kupferstecher
[February 13, 2026, 10:29:53 pm]
AVRPascal – free code edi...
by
ackarwow
[February 13, 2026, 10:08:59 pm]
Select rectangle of the i...
by
backprop
[February 13, 2026, 08:16:27 pm]
How to determine the unkn...
by
LV
[February 13, 2026, 07:37:32 pm]
how to enable multihelper...
by
mas steindorff
[February 13, 2026, 07:03:20 pm]
Lazarus/FreePascal Bug
by
Bart
[February 13, 2026, 06:27:28 pm]
Questions from a Windows ...
by
CM630
[February 13, 2026, 06:15:33 pm]
Duplicated icon in the Wi...
by
w click
[February 13, 2026, 05:47:49 pm]
AdvancedHTTPServer: A Go-...
by
LeP
[February 13, 2026, 03:01:15 pm]
Status of FPC 3.4.0 or FP...
by
gidesa
[February 13, 2026, 12:35:41 pm]
Notetask 1.1.1 - Free cro...
by
AlexanderT
[February 13, 2026, 12:00:08 pm]
Bee Hive solitaire
by
TBMan
[February 13, 2026, 03:22:09 am]
AI Created Music
by
Tony Stone
[February 13, 2026, 03:02:08 am]
Send form to true left an...
by
mas steindorff
[February 13, 2026, 02:39:34 am]
Help needed compiling
by
jamie
[February 13, 2026, 02:33:02 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: randomrange (Read 266 times)
BubikolRamios
Sr. Member
Posts: 382
randomrange
«
on:
December 06, 2025, 10:07:36 am »
Is that really useful for small ranges ?
I can tell there are 1000+ just 1 before and 1000+ just 2 after (see image)
randomize does no change anything at all.
Code: Pascal
[Select]
[+]
[-]
for
...
begin
randomize
(
)
;
random12
:
=
RandomRange
(
1
,
3
)
;
SynEdit1
.
Lines
.
Add
(
IntToStr
(
random12
)
)
;
end
;
Any suggestion ?
«
Last Edit: December 06, 2025, 10:20:01 am by BubikolRamios
»
Logged
lazarus 3.2-fpc-3.2.2-win32/win64
Thaddy
Hero Member
Posts: 18729
To Europe: simply sell USA bonds: dollar collapses
Re: randomrange
«
Reply #1 on:
December 06, 2025, 10:21:24 am »
I don't see anything wrong.
A random in the range 1..3 is returned. 3 is not part of the range... see:
https://www.freepascal.org/docs-html/rtl/math/randomrange.html
So the function can only return 1 or 2 and it does.
Code: Pascal
[Select]
[+]
[-]
//tested with
{$ifdef fpc}{$mode objfpc}{$endif}
uses
math
;
type
range
=
0
..
999
;
var
i
:
integer
;
begin
randomize
;
for
i
in
range
do
writeln
(
i
:
5
,
randomrange
(
1
,
3
)
:
2
)
;
end
.
If 3 needs to be included, make the upper range 4.
«
Last Edit: December 06, 2025, 10:30:27 am by Thaddy
»
Logged
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...
BubikolRamios
Sr. Member
Posts: 382
Re: randomrange
«
Reply #2 on:
December 06, 2025, 10:36:19 am »
Ahh, forget that, works fine. Had SynEdit1.Lines.Add(IntToStr(random12 )) inside wrong loop.
Thanks.
Logged
lazarus 3.2-fpc-3.2.2-win32/win64
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
General
»
randomrange
TinyPortal
© 2005-2018