[fpc-pascal] representation of a number

Daniel Franzini daniel.franzini at gmail.com
Sun Apr 1 19:02:21 CEST 2007


Hi all

I'm having some fun solving some programming problems in SPOJ
(www.spoj.pl, very very cool, check it out). The thing is that is need
to calculate some big fatorials (~100!). With FPC and the standard
integer types I was unable to perform the correct calculations because
100! is bigger than the largest number which can be represented with
those types. So I moved to the extended type and it worked quite well,
performing correct calculations and giving correct results. I started
wondering is this was a smart decision or if it is completely stupid
(i'm new to programming competitions and stuff like that).

The problem is that I'm unable to write the complete number on stdout.
Using extended I could only use scientific notation, which the judge
software does not seems to like. Question: what would be the correct
way to write the number on screen without using scientific notation
e.g.: 5! = 120 and not 5! = 1.2E+2?

-- 
Daniel

"Let us change our traditional attitude to the construction of
programs. Instead of imagining that our main task is to instruct a
computer what to do, let us concentrate rather on explaining to human
beings what we want a computer to do." (Donald Knuth)

"Yes, technogeeks can be funny, even if only to each other."
(http://www.boogieonline.com/revolution/science/humor/)"

"Man is driven to create; I know I really love to create things. And
while I'm not good at painting, drawing, or music, I can write
software." (Yukihiro Matsumoto, a.k.a. ``Matz'')



More information about the fpc-pascal mailing list