Tilted Forum Project - TFP - Sexuality, Philosophy and Political Discussion

Go Back   Tilted Forum Project - TFP - Sexuality, Philosophy and Political Discussion > Interests > Tilted Technology

Reply
 
LinkBack Thread Tools
Old 10-26-2004, 06:23 PM   #1 (permalink)
Junkie
 
zero2's Avatar
 
Join Date: Jul 2003
Is there a special character for squaring a number?

Im using c as the programming language, and the formula I have calls for s to be squared {s*s}, other than just typing s*s is there a special symbol for squaring?

s2 + p * (s - x) * (p + y)
zero2 is offline   Reply With Quote
Old 10-26-2004, 06:40 PM   #2 (permalink)
Crazy
 
Join Date: May 2004
Location: here and there
POW(3) Linux Programmer's Manual POW(3)

NAME
pow, powf, powl - power functions

SYNOPSIS
#include <math.h>

double pow(double x, double y);

float powf(float x, float y);

long double powl(long double x, long double y);

DESCRIPTION
The pow() function returns the value of x raised to the power of y.

ERRORS
The pow() function can return the following error:

EDOM The argument x is negative and y is not an integral value. This
would result in a complex number.

CONFORMING TO
SVID 3, POSIX, BSD 4.3, ISO 9899. The float and the long double vari-
ants are C99 requirements.

SEE ALSO
sqrt(3), cbrt(3)

2002-07-27 POW(3)
(END)
__________________
# chmod 111 /bin/Laden
theFez is offline   Reply With Quote
Old 10-28-2004, 01:21 PM   #3 (permalink)
Junkie
 
zero2's Avatar
 
Join Date: Jul 2003
thanks for the help.
zero2 is offline   Reply With Quote
Old 10-28-2004, 06:31 PM   #4 (permalink)
Crazy
 
Join Date: May 2004
Location: here and there
of course if you are using C++ you could overload say ^ to implement the pow function and it would be as easy as s^2 to square s. but i dont really know anything about operator overloading in C and quick searches really provided no information.
__________________
# chmod 111 /bin/Laden
theFez is offline   Reply With Quote
Old 10-28-2004, 07:58 PM   #5 (permalink)
Rookie
 
Join Date: Jun 2004
The code is much faster if you use s*s (relatively speaking).
jk777 is offline   Reply With Quote
Old 10-29-2004, 08:43 AM   #6 (permalink)
Crazy
 
Join Date: May 2004
Location: here and there
yeah, in the case of straight up squaring the s*s is definitely faster. but for situations where you need to raise to higher powers or to an unknown power (variable) the pow function would be better.

from what i understand there is no exponentation operator in c because few processors have exponentation instructions.
__________________
# chmod 111 /bin/Laden
theFez is offline   Reply With Quote
Old 11-12-2004, 12:22 AM   #7 (permalink)
Rookie
 
Join Date: Sep 2004
Location: Australia
Efficiency depends on the implementation of the power raising function.
This is generally done via logarithmic operations.
So for small powers like s^2 are done much more quickly as s*s, since this is a quicker operation in itself and saves the setup for a new method call.
Once you get into higher powers, it becomes much more efficient to use logarithms, and it gives you an easy way to calculate non-integer powers.
archer is offline   Reply With Quote
Old 11-12-2004, 12:49 PM   #8 (permalink)
Rookie
 
Join Date: Sep 2004
pow = suck. Pow introduces a significant slowdown. hardocde the instruction s*s. unless you will be using an exponent other than 2.
nlong is offline   Reply With Quote
Reply

Bookmarks

Tags
character, number, special, squaring

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT -7. The time now is 12:53 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
All text (c) 2002-2008 Tilted Forum Project
"Insignia" vBulletin 3.5 - b6gm6n - x7x7x7.com