Big Numbers

Previous pageNext page

"Our standard arithmetic benchmark (try this in C++ or Java)!"

1000 factorial.

 


Either copy the above into a Workspace window or type it in. Once again, position the cursor anywhere on the line with the actual expression ("1000 factorial") and then type Ctrl+D to evaluate it and display the result. You should get a (very) big number.

This example shows a couple of things. First, Smalltalk arithmetic is capable of adapting itself to the type and size of numbers involved. You don't have to know whether the result will be a floating point number, a fraction or a large or small integer, the Smalltalk class library will handle it automatically. Secondly, the Dolphin large integer arithmetic is pretty fast. In fact, most of the time in this example was spent actually displaying the result rather than calculating it!

Again, hit the DEL key while the answer is highlighted to delete it. If you have accidentally un-highlighted the text you'll have to select it again first before getting rid of it .

If you're one of those people who just can't help going off and pushing the boundaries, just be careful here if you want to try out larger and larger factorials as the calculations can get very big, very quickly. Please don't try out anything larger than 10,000 factorial, especially if you are displaying the result -- otherwise you'll be in for a rather long wait. Normally, if you give Dolphin something to do which takes a long time you can break out of it using Ctrl+Break. In this case, however, the large integer calculations are performed at such a low level that the break request will not be serviced and you'll have to kill the Dolphin environment from the task manager. Not very graceful!

Remember, to get back to these experiments just choose Help/First Splash in any Dolphin tool window.