• Post Reply Bookmark Topic Watch Topic
  • New Topic

[ask] how to calculate 128 bit number  RSS feed

 
Alfonsus Hartanto
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello guys, i just curious. how could i calculate a number that have more than 64 bit, let say 128 bit. Because as we know, the biggest primitive variable is long, which is 64 bit.

and if I calculate something, can i know how much time computers need/spend to calculate it?

thanks,, sorry for my english, im not english speaker anyway...
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check out the BigInteger class.
 
Alfonsus Hartanto
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok thank you... i understand then...
oh ya, another question, how could I know how much time computer spend to calculate certain operation...
thanks...
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh ya, another question, how could I know how much time computer spend to calculate certain operation...


This will be taught in your algorithms class.

And if you took algorithms already and don't recall. Remember that whole study on how an algorithm scales (big O notation)? Basically, once you figure out how something scales, you can take a few large samplings (but still tolerable in time) and from that, extrapolate how long it will take for an even larger calculation to take.

Henry
 
salvin francis
Bartender
Posts: 1653
37
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To calculate time....


get the time in milliseconds before the calculation (say t1)
get the time in milliseconds after the calculation (say t2)

To know the time spent in milliseconds, calculate difference (say t2-t1)
 
Campbell Ritchie
Marshal
Posts: 56540
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For many speed calculations the method in the System class which gives time in nanoseconds will be necessary. Even 1000000 operations will probably be too fast for the millisecond method to be accurate.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!