locked
Help with Converting Formula in C to vb.net RRS feed

  • Question

  • User1958078207 posted

    Please help.  I am reproducing a program written in C to vb.net and I am getting different results on a math formula.  I am sure it is something simple that I am overlooking.


    Here is the formula in C

    num = (10 * 9 * 80900 * 0501) & 0xffff;


    Here is the same formula in vb.net

    num = (10 * 9 * 80900 * 0501) AND &HFF

    Friday, October 9, 2009 3:28 PM

Answers

  • User397347636 posted

    "0501" in C is an octal literal - the VB equivalent is "&O501":

    num = (10 * 9 * 80900 * &O501) And &Hffff

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 9, 2009 6:18 PM

All replies

  • User1164098974 posted

    What is the output you are getting from each?


    Friday, October 9, 2009 5:16 PM
  • User1958078207 posted

    Results in C: (10 * 9 * 80900 * 0501) & 0xffff = 56168

    Results in vb.net : (10 * 9 * 80900 * 0501) AND &HFF = 47240


    Friday, October 9, 2009 6:03 PM
  • User397347636 posted

    "0501" in C is an octal literal - the VB equivalent is "&O501":

    num = (10 * 9 * 80900 * &O501) And &Hffff

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 9, 2009 6:18 PM