Path: news.cs.au.dk!not-for-mail From: datpete@mjolner.dk Newsgroups: comp.lang.beta Subject: Re: Problem with %getByte Date: 16 Feb 1999 10:56:16 -0000 Organization: Mjolner Informatics ApS Lines: 58 Approved: mailtonews@cs.au.dk Distribution: world Message-ID: <19990216105616.21705.qmail@noatun.mjolner.dk> Reply-To: datpete@mjolner.dk NNTP-Posting-Host: daimi.cs.au.dk X-Trace: xinwen.cs.au.dk 919162592 3297 255.255.255.255 (16 Feb 1999 10:56:32 GMT) X-Complaints-To: news@cs.au.dk NNTP-Posting-Date: 16 Feb 1999 10:56:32 GMT Xref: news.cs.au.dk comp.lang.beta:11823 Karl Waclawek writes: > In my quest for speeding up my CRC program (it runs about > 10 times as slow as my Delphi-coded equivalent I looked > into the basic libraries code to see how they do it there. > > Doing that, I found that the putHex function did not work > properly. I traced the problem back to the %getByte function, > which returns incorrect values depending on the context. > Just run the following program. It prints out the Byte values > of an integer variable, first using the constants 3, 2, 1 and 0 > as input to %getByte, then using the loop variable in a for loop. > On my machine (Beta release 4.1) the outputs are different, i.e. > the for loop produces incorrect output. > > > ORIGIN '~beta/basiclib/v1.6/betaenv' > -- program: Descriptor -- > (# > TestInt, j: @Integer; > do > 16x20304050 -> TestInt; > 'Using Constants\n' -> putText; > 'Byte Index: 3 Byte Value: ' -> putText; > 3 -> TestInt.%getByte -> putInt; '\n' -> putText; > 'Byte Index: 2 Byte Value: ' -> putText; > 2 -> TestInt.%getByte -> putInt; '\n' -> putText; > 'Byte Index: 1 Byte Value: ' -> putText; > 1 -> TestInt.%getByte -> putInt; '\n' -> putText; > 'Byte Index: 0 Byte Value: ' -> putText; > 0 -> TestInt.%getByte -> putInt; '\n' -> putText; > 'Using a For loop\n' -> putText; > (for i: 4 repeat > (4-i) -> j; > 'Byte Index: ' -> putText; j -> putInt; > ' ' -> putText; 'Byte Value: ' -> putText; > j -> TestInt.%getByte -> putInt; '\n' -> putText; > for); > #) I can confirm your observations. The problem is present in release 4.1 on intel based platforms (Linux, Windows). I have just checket, that the bug is indeed fixed in the next major release (5.0), which will be out later this year (I cannot be more specific at the current time, sorry). Sincerely, Peter Andersen, Mjolner Informatics