Ask Your Question
0

Type error in sage: long is too large to convert to float

asked 2016-05-02 07:09:10 +0100

Node.js gravatar image

I am new in sage and I have been trying for hours to fix the type issue. I used every possible data type in Python (e.g. Decimal, long and etc.) but no luck. I don't want to introduce a new data type in code. It would be great if the error could be fixed and X and Y be long a data type. Thank you so much in Advance.

Code:

 N = long(
    '16260595201356777876687102055392856230368799478725437225418970788404092751540966827614883675066492383688147288741223234174448378892794567789551235835087027626536919406320142455677084743499141155821894102610573207343199194327005172833989486958434982393556326206485954223151805798621294965926069728816780985683043030371485847746616146554612001066554175545753760388987584593091716701780398711910886679925612838955858736102229719042291682456480437908426849734556856917891628730543729446245974891735371991588505429152639045721840213451875487038496578525189542369448895368117152818687795094021869963915318643663536132393791')

e = long(
    '9278586176415637407263159408578691920359333372454377369719770617047980280946772628715887544861771332603998512490412112310956902919491486170574088276198189495386333836465063768828129359301433517440718437381660454785705721525097974857636068871096713768626273297901238473071056637845492072479070936932798180576585796558683754435768607883046039584737510259185971806751698550158026249176801507619064529443818304150648599396688870660401080227889827572469510021064725085334872793878678034795523371228947902585424135292996464136649558065449053206564552616679643325831942423442776280981153068472730957010986456115236454025653')

delta = float(0.26)
m = 4

t = int((1 - 2 * delta) * m)
X = 2 * floor(N ^ delta)
Y = floor(N ^ (1 / 2))

Error:

Traceback (most recent call last):   File "RSA/boneh_durfee.sage.py", line 306, in <module>
    X = _sage_const_2  * floor(N ** delta)  # this _might_ be too much OverflowError: long int too large to convert to float
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-05-02 15:11:03 +0100

B r u n o gravatar image

I do not know exactly what you want to do. A solution is simply to let Sage decide the type of your data, and it works fine. If you really need, you can at the end cast the results you get as long:

sage: N = 16260595201356777876687102055392856230368799478725437225418970788404092751540966827614883675066492383688147288741223234174448378892794567789551235835087027626536919406320142455677084743499141155821894102610573207343199194327005172833989486958434982393556326206485954223151805798621294965926069728816780985683043030371485847746616146554612001066554175545753760388987584593091716701780398711910886679925612838955858736102229719042291682456480437908426849734556856917891628730543729446245974891735371991588505429152639045721840213451875487038496578525189542369448895368117152818687795094021869963915318643663536132393791
sage: e = 9278586176415637407263159408578691920359333372454377369719770617047980280946772628715887544861771332603998512490412112310956902919491486170574088276198189495386333836465063768828129359301433517440718437381660454785705721525097974857636068871096713768626273297901238473071056637845492072479070936932798180576585796558683754435768607883046039584737510259185971806751698550158026249176801507619064529443818304150648599396688870660401080227889827572469510021064725085334872793878678034795523371228947902585424135292996464136649558065449053206564552616679643325831942423442776280981153068472730957010986456115236454025653
sage: delta = 0.26
sage: m = 4
sage: t = floor((1 - 2*delta) * m)
sage: X = 2 * floor(N^delta)
sage: Y = floor(N^(1/2))
sage: long(X)
32803899270297070621193977210731234596426011189989730481205367370572340252530823123935195892838208219967066426399488721710159859316222019683979411877007525412864L
sage: long(Y)
127517038866799200297242821855120159560537172736237774965548822592486953009486344046149894274027863945891695034796248608733215708336298908651544487154454966444303900338262061989468695845390725264270930561135688549398831506715374871115720837441254679481355465619731364817176382308337998166956161420882909016415L
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

1 follower

Stats

Asked: 2016-05-02 07:07:02 +0100

Seen: 1,982 times

Last updated: May 02 '16