Ask Your Question
1

Can I convert integermod_int to int?

asked 2018-04-30 10:34:46 -0600

malloc123 gravatar image

I need to do an and operation between element of vector with IntegerModRing(mynumber), but I get

if(element==(element & 3)): TypeError: unsupported operand type(s) for &: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' and 'int'

don't mind element ==element(&3) It's just to see if works.

for element in v0:
  if(element==(element & 3)):
    print "ok"

is there a function that let me do this?

edit retag flag offensive close merge delete

Comments

Welcome to Ask Sage! Thank you for your question!

slelievre gravatar imageslelievre ( 2018-04-30 11:49:07 -0600 )edit

Can you provide minimal complete code allowing to reproduce the issue?

Some code that other users can copy and paste in a Sage session to see for themselves what goes wrong, and explore how to solve the issue.

slelievre gravatar imageslelievre ( 2018-04-30 11:49:49 -0600 )edit

To display inline code, like z = x*y, use backticks.

To display blocks of code or error messages, skip a line above and below, and do one of the following (all give the same result):

  • indent all code lines with 4 spaces
  • select all code lines and click the "code" button (the icon with '101 010')
  • select all code lines and hit ctrl-K

For instance, typing

If we define `f` by

    def f(x, y):
        return (x, y)

then `f(2, 3)` returns `(2, 3)` but `f(2)` gives:

    TypeError: f() takes exactly 2 arguments (1 given)

produces:

If we define f by

def f(x, y):
    return (x, y)

then f(2, 3) returns (2, 3) but f(2) gives:

TypeError: f() takes exactly 2 arguments (1 given)

Please edit your question to do that.

slelievre gravatar imageslelievre ( 2018-04-30 11:50:30 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-04-30 11:38:21 -0600

nbruin gravatar image
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2018-04-30 10:34:46 -0600

Seen: 48 times

Last updated: Apr 30