Results 1 to 4 of 4

Thread: fraction exponents

  1. #1
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default fraction exponents

    i'm trying to do exponents in scar, but my problem is, how would i do it when a fraction is the exponent?

    i has
    SCAR Code:
    function exponent(num, by : integer) : extended;
    var
      i : integer;
    begin
      result := num
      for i := 0 to by do
        result := result * num;
    end;

    just for whole numbers
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  2. #2
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Code:
    function Pow(Base, Exponent: Extended): Extended;
    Returns the power of the Base with the given Exponent.
    
    function IntPow(Base: Extended; Exponent: Integer): Extended;
    Returns the power of the Base with the given Exponent. Whole number exponents only.
    F1

  3. #3
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by IceFire908 View Post
    Code:
    function Pow(Base, Exponent: Extended): Extended;
    Returns the power of the Base with the given Exponent.
    
    function IntPow(Base: Extended; Exponent: Integer): Extended;
    Returns the power of the Base with the given Exponent. Whole number exponents only.
    F1
    damn names.

    i was looking for "exponent" or "exp" in scar, should used ctrl+f .
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  4. #4
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Awkwardsaw View Post
    damn names.

    i was looking for "exponent" or "exp" in scar, should used ctrl+f .
    Yea Pow should work... anways...It's not quite right yet... but I started to make you the source

    SCAR Code:
    function FracExponent(Base, Exponent: Extended): Extended;
    var
      I, E: LongInt;
      S, B: string;
    begin
      S := Replace(FloatToStr(DecRet(Exponent)), '0.', '');
      B := IntToStr(Floor(Exponent));
      E := StrToIntDef(B + S, 0);
      Result := Base;
      for I := 0 to Floor(Abs(E)) do
        Result := Result * Base * (E / (IntPow(10, Length(S))));
    end;


    Yea... still not quite right

    Edit:
    X^Y <=> e^(ln(X^Y)) <=> e^(Y*ln(X))
    Last edited by Wanted; 01-06-2010 at 12:44 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •