Results 1 to 15 of 15

Thread: Simple Math Problem

  1. #1
    Join Date
    Dec 2007
    Location
    Wizzup?'s boat
    Posts
    1,013
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Simple Math Problem

    This should be quick,

    Q. How do I make 3400 into 3.4? When I say;

    SCAR Code:
    procedure ConvertThatSOB;
    var
      Number : longint;
    begin
      Number := 3400 / 1000;
      Writeln(FloatToStr(Number));
    end;

    ..the answer comes out as "3".
    Project: Welcome To Rainbow

  2. #2
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Shouldnt it be an Extend?
    And

    Writeln(inttostr(Number));
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  3. #3
    Join Date
    Dec 2007
    Location
    Wizzup?'s boat
    Posts
    1,013
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ill try it

    SCAR Code:
    3
    Successfully executed

    Nope Didnt work
    Project: Welcome To Rainbow

  4. #4
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    SCAR Code:
    procedure ConvertThatSOB;
    var
      Number : Extended;
    begin
      Number := 3400.0 div 1000.0;
      Writeln(FloatToStr(Number));
    end;

    Eureeka!

    Try it! The numbers need decimal points.
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  5. #5
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    SCAR Code:
    program New;
    begin
      WriteLn(FloatToStr(3400.0 / 1000.0));
    end.

    Successfully compiled (367 ms)
    3.4
    Successfully executed
    Like that?

    EDIT: noidea has the right idea (go figure! ).
    :-)

  6. #6
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Method, yours it prolly faster
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  7. #7
    Join Date
    Dec 2007
    Location
    Wizzup?'s boat
    Posts
    1,013
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks Method and noidea! Ok, one more problem....

    How do i make "3400" to "3400.0" through scripting??

    Note: 3400 will always be a whole number
    Project: Welcome To Rainbow

  8. #8
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    3400.0 is a whole number
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  9. #9
    Join Date
    Sep 2006
    Location
    include srl/srl.scar ( aussie)
    Posts
    2,875
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by noidea View Post
    Method, yours it prolly faster
    No i timed, there both..

    538156843

    538200843

  10. #10
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Cool! Mines faster!
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  11. #11
    Join Date
    Dec 2007
    Location
    Wizzup?'s boat
    Posts
    1,013
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by noidea View Post
    3400.0 is a whole number
    i mean that "3400" will be changing

    so it will be

    SCAR Code:
    if(JugsCollected >= 1000)then
    begin
      JugsCollected := JugsCollected / 1000;
      JugsFinal := FloatToStr(JugsCollected)+'K';
    end;


    and JugsCollected will always be a whole number, so how do i add the ".0" on the end so that the function works?
    Project: Welcome To Rainbow

  12. #12
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    There is no .0 on the end. Just change its type to Extended, and if there's a decimal involved, you'll get one.
    :-)

  13. #13
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    SCAR Code:
    program New;
    var
      JugsCollected: Extended;
      JugsFinal: String;
    begin
      JugsCollected := 1000;
      if(JugsCollected >= 1000)then
      begin
        JugsCollected := JugsCollected / 1000;
        JugsFinal := FloatToStr(JugsCollected + 0.0)+'K';
        Writeln((JugsFinal));
      end;
    end.

    Run that. Is it what your looking for?

    Nvm, Method got it this time
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  14. #14
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    Quote Originally Posted by NiCbaZ View Post
    No i timed, there both..

    538156843

    538200843
    I sure hope neither of ours took 538,000,000 ms to run. I assume you just used GetSystemTime, which gets the current clock time, not the difference between one time and another.
    :-)

  15. #15
    Join Date
    Dec 2007
    Location
    Wizzup?'s boat
    Posts
    1,013
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    sweet, thanks guys
    Project: Welcome To Rainbow

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Simple Script Request Involving Math
    By sollek in forum RS3 Outdated / Broken Scripts
    Replies: 1
    Last Post: 08-18-2007, 12:58 PM

Posting Permissions

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