Page 1 of 1

help...

Posted: Sat Aug 13, 2011 11:00 am
by shu7734
bb.l=(64<<5/2)%65

Debug bb


result is 49

In Visual C++ Or Perl Or Other language

#include "stdafx.h"
#include <stdio.h>


int _tmain(int argc, _TCHAR* argv[])
{
int aa=0;
aa=(64<<5/2)%65;
printf("%d",aa);
return 0;
}

result is 61

Re: help...

Posted: Sat Aug 13, 2011 11:41 am
by gnozal

Code: Select all

bb.l=(64<<5/2)%65 ;-> 49
Debug bb
; same as
bb.l=((64<<5)/2)%65 ;-> 49
Debug bb
; because '<<' has priority over '/'
bb.l=(64<<(5/2))%65 ;-> 61
Debug bb
From PB manual :

Code: Select all

  Priority Level |     Operators
  ---------------+---------------------
       8 (high)  |      ~, -
       7         |    <<, >>, %, !
       6         |       |, &
       5         |       *, /
       4         |       +, -
       3         | >, >=, <, <=, =, <>
       2         |       Not
       1 (low)   |  And, Or, XOr

Re: help...

Posted: Sat Aug 13, 2011 11:48 am
by shu7734
thanks ,i tride add the (),and know it,Why are you(purebasic) different from the others

I have been accustomed to so use the << and /



so sorry for my poor english