[futurebasic] Re: [FB] FB Help Error - FYI

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 2010 : Group Archive : Group : All Groups

From: Jay Reeve <jayreeve@...>
Date: Fri, 29 Jan 2010 09:16:33 -0600
Robert,

FB has always allowed for bit-shifting real numbers whereby they  
would be multiplied or divided by the appropriate (and possibly non- 
integer) power of 2. In FB4,
  print pi << 3  ..... Produces.....  25.1327412287
and
  print pi << pi ..... Produces.....  27.7244855096

Hence the reference to real numbers in the explanation. Is that no  
longer the case? Should it be?

If that is still correct, you would only need to eliminate the  
statement that "Both operands must be integral values."

Also, I think a bit shift greater than the width of the first operand  
is not (and should not be) undefined. In FB4,
  dim a as unsigned byte
  a =129
  print a >> 7, a >> 9, a << 7, a << 9
properly yields
  1               0               16512           66048

   e-e
   =J= a  y
    "

On Jan 29, 2010, at 12:36 AM, Robert Purves wrote:

>
> Stu Cram wrote:
>
>> While reading the FB Help ---> Appendix D (Mathematical operators...)
>> I noticed the following error:
>> <pastedGraphic.tiff>
>> For << , it should say multiplied not divided, I think.
>> (See highlighted word in the image above.)
>
> The entries for the shift operators are indeed wrong. Something  
> like this would be more satisfactory:
>
>   <<
> The first operand is shifted left by the number of bit positions  
> specified by the second operand. Both operands must be integral  
> values. A left shift by n is equivalent to multiplying by 2^n. The  
> result is undefined if n is negative or greater than the width in  
> bits of the first operand.
>
>>>
> The first operand is shifted right by the number of bit positions  
> specified by the second operand. Both operands must be integral  
> values. A right shift by n is equivalent to dividing by 2^n with  
> rounding towards minus infinity. The result is undefined if n is  
> negative or greater than the width in bits of the first operand.
>
> Robert P.
>
> --
> To unsubscribe, send ANY message to: futurebasic- 
> unsubscribe@...
>
>