Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: SET /A Command  (Read 2476 times)

0 Members and 1 Guest are viewing this topic.

Woodman

    Topic Starter


    Beginner
    SET /A Command
    « on: January 15, 2008, 03:24:32 PM »
    Win.XP Home SP.2

    How can I get the Set/a command to return the complete value???

    Example:

    @echo off
    cls

    set a=1029

    set /a b=%a%/2

    echo %b%

    returns 514 which should (hopefully) be 514.5

    Where have I got it wrong please???

    Thanks

    gpl



      Apprentice
    • Thanked: 27
      Re: SET /A Command
      « Reply #1 on: January 15, 2008, 05:02:14 PM »
      You didnt go wrong .. you can only do integer maths, which means that any fraction is dropped off

      You could try multiplying your number by 10, doing the division and inserting a '.' to the left of the rightmost digit.

      Woodman

        Topic Starter


        Beginner
        Re: SET /A Command
        « Reply #2 on: January 15, 2008, 05:57:53 PM »
        Quote from: gpl
        you can only do integer maths, which means that any fraction is dropped off

        Thank you, I must have missed that very important condition in the SET/? display which I will re-read.