# Bitwise shift operator not found

**URL:** <https://discourse.ats-lang.org/t/bitwise-shift-operator-not-found/443>\
**Category:** Google Group\
**Created:** [June 24, 2014, 5:10pm UTC](https://discourse.ats-lang.org/t/bitwise-shift-operator-not-found/443 "2014-06-24T17:10:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Justin\_Smith](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@Justin\_Smith](https://discourse.ats-lang.org/u/Justin_Smith)\
**Post date:** [June 24, 2014, 5:10pm UTC](https://discourse.ats-lang.org/t/bitwise-shift-operator-not-found/443/1 "2014-06-24T17:10:18Z")

</div>

fun first1 {ndx:int | ndx \>= 1} (ndx: ulint ndx, nzer: ulint): (ulint, ulint  
) =  
if (ndx land 1ul) = 0ul  
then first1 ((ndx \>\> 1ul), nzer + 1ul)  
else (ndx, nzer)

the above code gives the following error:

error(3): the symbol [\>\>] cannot be resolved as no match is found.

as you can see, I tried to introduce a dependent type, mostly in  
speculation of the conditions where the compiler would approve of a bit  
shift, or consider it “safe”

Is there a general overview for bitwise operations in ats2? I haven’t been  
able to find anything in the html book from the main site.

---

<div class="post-metadata">

**Author:** ![gmhwxi](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gmhwxi](https://discourse.ats-lang.org/u/gmhwxi)\
**Post date:** [June 25, 2014, 2:00am UTC](https://discourse.ats-lang.org/t/bitwise-shift-operator-not-found/443/2 "2014-06-25T02:00:18Z")

</div>

ndx \>\> 1ul

should be

ndx \>\> 1

However, the typechecker does not know that ndx \>\> 1 yields a nonzero  
integer in this case. So you  
will encounter a type-error.On Tuesday, June 24, 2014 1:10:18 PM UTC-4, Justin Smith wrote:

> fun first1 {ndx:int | ndx \>= 1} (ndx: ulint ndx, nzer: ulint): (ulint,  
> ulint) =  
> if (ndx land 1ul) = 0ul  
> then first1 ((ndx \>\> 1ul), nzer + 1ul)  
> else (ndx, nzer)
> 
> the above code gives the following error:
> 
> error(3): the symbol [\>\>] cannot be resolved as no match is found.
> 
> as you can see, I tried to introduce a dependent type, mostly in  
> speculation of the conditions where the compiler would approve of a bit  
> shift, or consider it “safe”
> 
> Is there a general overview for bitwise operations in ats2? I haven’t been  
> able to find anything in the html book from the main site.

---

<div class="post-metadata">

**Author:** ![gmhwxi](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gmhwxi](https://discourse.ats-lang.org/u/gmhwxi)\
**Post date:** [June 25, 2014, 2:22am UTC](https://discourse.ats-lang.org/t/bitwise-shift-operator-not-found/443/3 "2014-06-25T02:22:32Z")

</div>

This version typechecks:

fun  
first1{i:pos}  
(  
ndx: ulint(i), nzer: uint  
) : (ulint, uint) =  
(  
if  
iseqz (ndx land 1ul)  
then let  
val ndx = ndx \>\> 1  
val [i:int] ndx = g1ofg0 (ndx)  
prval () = \_\_assert () where  
{  
extern praxi \_\_assert (): [i \>= 1] void  
}  
in  
first1 (ndx, succ(nzer))  
end // end of [then]  
else (ndx, nzer) // end of [else]  
) (\* end of [first1] \*)On Tuesday, June 24, 2014 1:10:18 PM UTC-4, Justin Smith wrote:

> fun first1 {ndx:int | ndx \>= 1} (ndx: ulint ndx, nzer: ulint): (ulint,  
> ulint) =  
> if (ndx land 1ul) = 0ul  
> then first1 ((ndx \>\> 1ul), nzer + 1ul)  
> else (ndx, nzer)
> 
> the above code gives the following error:
> 
> error(3): the symbol [\>\>] cannot be resolved as no match is found.
> 
> as you can see, I tried to introduce a dependent type, mostly in  
> speculation of the conditions where the compiler would approve of a bit  
> shift, or consider it “safe”
> 
> Is there a general overview for bitwise operations in ats2? I haven’t been  
> able to find anything in the html book from the main site.

---

<div class="post-metadata">

**Author:** ![Brandon\_Barker](https://sea1.discourse-cdn.com/flex019/user_avatar/discourse.ats-lang.org/brandon_barker/32/61_2.png) [@Brandon\_Barker](https://discourse.ats-lang.org/u/Brandon_Barker)\
**Post date:** [June 24, 2014, 10:02pm UTC](https://discourse.ats-lang.org/t/bitwise-shift-operator-not-found/443/4 "2014-06-24T22:02:06Z")

</div>

My understanding is that this sort of low level mechanism might be best  
left to implementing (possibly inline) in C:  
[http://www.ats-lang.org/DOCUMENT/INT2PROGINATS/HTML/c1995.html](http://www.ats-lang.org/DOCUMENT/INT2PROGINATS/HTML/c1995.html)

Brandon Barker  
brandon…@gmail.comOn Tue, Jun 24, 2014 at 1:10 PM, Justin Smith [noise...@gmail.com](mailto:noise...@gmail.com) wrote:

> fun first1 {ndx:int | ndx \>= 1} (ndx: ulint ndx, nzer: ulint): (ulint,  
> ulint) =  
> if (ndx land 1ul) = 0ul  
> then first1 ((ndx \>\> 1ul), nzer + 1ul)  
> else (ndx, nzer)
> 
> the above code gives the following error:
> 
> error(3): the symbol [\>\>] cannot be resolved as no match is found.
> 
> as you can see, I tried to introduce a dependent type, mostly in  
> speculation of the conditions where the compiler would approve of a bit  
> shift, or consider it “safe”
> 
> Is there a general overview for bitwise operations in ats2? I haven’t been  
> able to find anything in the html book from the main site.
> 
> –  
> You received this message because you are subscribed to the Google Groups  
> “ats-lang-users” group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [ats-lang-user...@googlegroups.com](mailto:ats-lang-user...@googlegroups.com).  
> To post to this group, send email to [ats-lan...@googlegroups.com](mailto:ats-lan...@googlegroups.com).  
> Visit this group at [http://groups.google.com/group/ats-lang-users](http://groups.google.com/group/ats-lang-users).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/ats-lang-users/d5769810-8030-4a1d-8aa9-7d640d47f66b%40googlegroups.com](https://groups.google.com/d/msgid/ats-lang-users/d5769810-8030-4a1d-8aa9-7d640d47f66b%40googlegroups.com)  
> [https://groups.google.com/d/msgid/ats-lang-users/d5769810-8030-4a1d-8aa9-7d640d47f66b%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/d5769810-8030-4a1d-8aa9-7d640d47f66b%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .
