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
Future Composer Player
by
Gigatron
[
Today
at 04:27:49 pm]
Object Inspector is "gone...
by
dsiders
[
Today
at 04:21:06 pm]
Rolling releases Lazarus[...
by
Okoba
[
Today
at 04:15:30 pm]
Animated Coloured Koch Fr...
by
Boleeman
[
Today
at 03:16:07 pm]
Rings for You ALL
by
Boleeman
[
Today
at 03:00:39 pm]
I want to port my LDL pr...
by
Boleeman
[
Today
at 02:44:25 pm]
Perlin Map 3D
by
Boleeman
[
Today
at 02:38:54 pm]
Lazarus for Windows on aa...
by
DonAlfredo
[
Today
at 02:35:18 pm]
would multi threading hel...
by
LeP
[
Today
at 01:38:42 pm]
What was your first compu...
by
Thaddy
[
Today
at 01:04:41 pm]
[SOLVED] Bass.dll equaliz...
by
d2010
[
Today
at 10:36:25 am]
Error rebuilding IDE afte...
by
JuhaManninen
[
Today
at 09:57:18 am]
IDE areas changing size
by
iru
[
Today
at 09:52:11 am]
TLazSerial : serial port ...
by
ccrause
[
Today
at 07:25:31 am]
Documentation Repositorie...
by
Martin_fr
[January 23, 2026, 08:15:38 pm]
Developing FreePascal on ...
by
HKPhysicist
[January 23, 2026, 05:00:26 pm]
Difference in formatting ...
by
Hartmut
[January 23, 2026, 09:30:18 am]
Lazarus Bugfix Release 4...
by
CM630
[January 23, 2026, 08:02:52 am]
OPC client with Lazarus
by
TheMouseAUS
[January 23, 2026, 04:56:43 am]
[Windows] UTF8 encoding w...
by
PascalDragon
[January 22, 2026, 09:51:05 pm]
Lazarus in Windows allowe...
by
vinntec
[January 22, 2026, 06:01:29 pm]
PasTemplates - a go-like ...
by
CynicRus
[January 22, 2026, 05:35:57 pm]
Strange Error when I use ...
by
TYDQ
[January 22, 2026, 03:14:50 pm]
FPCupDeluxe unable to bui...
by
Martin_fr
[January 22, 2026, 02:57:15 pm]
TRichMemo install shows "...
by
vinntec
[January 22, 2026, 01:36:50 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: randomrange (Read 254 times)
BubikolRamios
Sr. Member
Posts: 380
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: 18712
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: 380
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