delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/08/20:32:26

From: "JOA" <jsierra AT diandel DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: PROBLEM WITH FUNCTION RAND()
Date: Fri, 8 May 1998 21:29:23 +0200
Organization: Telefonica Transmision de Datos
Lines: 12
Message-ID: <6ivreu$jo5$2@talia.mad.ibernet.es>
NNTP-Posting-Host: iv13.diandel.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hello.
When i make a program (i want print a rand number into the screen) whit this
function or random function,and execute it a few times the random numbers
donīt change.
The function randomize() isn`t in the help of Rhide.
Thanks






    || __dpmi_lock_linear_region(&mi) < 0
>    || __dpmi_set_segment_base_address(ldt, ADDR) < 0

This is setting the segment base to the physical address of your device,
when it should be using the linear location (as it stands, there is no
point in making the address mapping at all because you don't do anything
with the linear address that it returns).

>    || __dpmi_set_segment_limit(ldt, 0x10000 - 1) < 0)
>    {
>        printf("physical mapping error\n");
>        exit(1);
>    }

Although this is technically correct (ANSI C guarantees shortcircuit
evaluation for chains of logical operations like this), I feel that it
is quite confusing to string all your function calls together like this.
Some pre-ANSI compilers might evaluate this construct in the wrong
order, and I had to look carefully at it before I could see that it was
ok. IMHO it would be much clearer if you did each of these calls as a
separate operation.


--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
"Miracles are nothing if you've got the wrong intentions" - Mike Keneally

- Raw text -


  webmaster     delorie software   privacy  
  Copyright Đ 2019   by DJ Delorie     Updated Jul 2019