Results 1 to 8 of 8

Thread: Decimals

  1. #1
    Join Date
    Sep 2008
    Location
    My House
    Posts
    519
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Decimals

    How to you get scar to convert an integer into a decimal. like if X := 50. How do you make X := 0.05

  2. #2
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    SCAR Code:
    program New;

    var I: Integer;
        E: Extended;

    begin
      I := 50;
      E := StrToFloat(IntToStr(I));
    end.
    Last edited by Frement; 05-16-2010 at 07:16 PM.
    There used to be something meaningful here.

  3. #3
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    SCAR Code:
    var
      x: Extended;
      i: Integer;

    begin
      i := 5;
      x := i + 0.0;
      Writeln('x: '+ToStr(x));
    end.

    Hope that helps.

    Frement! Bad practice to do some many conversions. :<

    And you never use S.

  4. #4
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Quote Originally Posted by i luffs yeww View Post
    SCAR Code:
    var
      x: Extended;
      i: Integer;

    begin
      i := 5;
      x := i + 0.0;
      Writeln('x: '+ToStr(x));
    end.

    Hope that helps.

    Frement! Bad practice to do some many conversions. :<

    And you never use S.
    I just couldnt think of any easier way then But after reading your post i felt stupid, anyway, i fixed the S before you edited, and GET ON MSN!!!
    There used to be something meaningful here.

  5. #5
    Join Date
    Sep 2008
    Location
    My House
    Posts
    519
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Those Both Don't work? Well Frements works but it only displays 50.

  6. #6
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    You have to run mine on Simba. Sorry.

    Basically, you just need to add 0.0 to an integer to make it extended.

  7. #7
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Quote Originally Posted by death12652 View Post
    Those Both Don't work? Well Frements works but it only displays 50.
    SCAR Code:
    program New;

    var I: Integer;
        E: Extended;

    begin
      I := 50;
      E := StrToFloat(IntToStr(I));
      E := E + 5.5;
      Writeln(E);
    end.

    Yes it does?
    There used to be something meaningful here.

  8. #8
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    Also, for your specific example..

    SCAR Code:
    var
      ext: Extended;
      int: Integer;
     
    begin
      int := 50;
      ext := int * 0.001;
      Writeln(ext);
    end.

    SCAR Code:
    Successfully compiled (102 ms)
    0.05
    Successfully executed

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
  •