Re: [Dev-C++] superscript for squares
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Mac R. <re...@no...> - 2002-06-13 20:51:31
|
>I could nor figure out how to use superscript for squares (like for example
>12 ) in DEV++ IDE . Can you please tell me is there a short cut for doing
>it or other method.
Unfortunately I am unsure what you are trying to do... "superscript" is a
typesetting issue, and unrelated to programming. What is "example 12"? I
am going to assume that you meant:
2
"like, for example, 1 "
If you are viewing this with proportional spaced fonts, I was attempting to
place a "1" with a raised superscripted "2" above it...
In an attempt to be useful, I will make a wild assumption and run with it.
If it isn't useful, I apologize.
If you are trying to raise one number to another power ( "one raised to the
second power", otherwise known as "one squared" ), the function you want is
pow(). In this particular example, it would be "pow(1,2)".
IMPORTANT : pow() is a general purpose, floating point routine, capable of
handling things like "pow(-13.9153, 9513.24351)", and because of that it is
extremely slow compared to other methods if you are doing simple powers.
If you are truly doing squares, the fastest method is to multiply the
number by itself... Rather than doing "xsquared = pow(x,2)", just do
"xsquared = x*x" and it will run a lot faster. If you are trying to raise
to a higher, but still integral power, (for example, "pow(3511.31451532,
17)") there are fast routines for doing that. I found them in intro
computer science books. They involve bit shifting and masking though,
which may be more involved that you want to get. If speed isn't a major
issue, just use pow().
Mac
-
_____________________________ /"\
Mac Reiter \ / ASCII Ribbon Campaign
Nomadics, Inc. X Against HTML Mail
re...@no... / \ (To join the campaign, simply use
this in your signature.)
|