Announcement

Collapse
No announcement yet.

How can I do this in PB? There is no function Pow()

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How can I do this in PB? There is no function Pow()

    Dear all,

    How can I this rewritten in PB statements/ functions this expression:

    Code:
    g_Frequency = pow_(CDBL(2 * g_PulseLength),CDBL(-1)) * 1000000
    Kind regards
    Stephane

  • #2
    pow_(CDBL(2 * g_PulseLength),CDBL(-1)) * 1000000
    Assume pow_(x,y) means x to the y power. If y = -1 that equals 1/x, so your expression amounts to

    1000000 / (2 * g_PulseLength)
    or
    500000 / g_PulseLength

    Assume CDBL means convert to double precision. For a double precision result use:

    500000# / CDbl(g_PulseLength)
    Politically incorrect signatures about immigration patriots are forbidden. Searching “immigration patriots” is forbidden. Thinking about searching ... well, don’t even think about it.

    Comment


    • #3
      Originally posted by Mark Hunter View Post
      Assume pow_(x,y) means x to the y power. If y = -1 that equals 1/x, so your expression amounts to

      1000000 / (2 * g_PulseLength)
      or
      500000 / g_PulseLength

      Assume CDBL means convert to double precision. For a double precision result use:

      500000# / CDbl(g_PulseLength)

      Thanks, for your very quick response :=)

      Comment


      • #4
        Well, if there is no Pow(), I suppose you could try Bang() or Smack().

        For all I know Snap(), Crackle() and Pop() may also be worth an effort.
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          Originally posted by Michael Mattias View Post
          Well, if there is no Pow(), I suppose you could try Bang() or Smack().

          For all I know Snap(), Crackle() and Pop() may also be worth an effort.
          Funny :=)

          Comment


          • #6
            Whilst there is not a POW function there is an equivalent operator which is "^".

            so your code would be :
            Code:
            g_Frequency = CDBL(2 * g_PulseLength) ^ CDBL(-1) * 1000000
            or if you really need a POW function you could try:
            Code:
            FUNCTION POW (x AS DOUBLE, y AS DOUBLE) AS DOUBLE
            
                FUNCTION = x ^ Y
            
            END FUNCTION
            Last edited by Neil Prichard; 27 Oct 2013, 01:35 PM. Reason: typo
            Kind regards,
            Neil

            http://www.BASICProgramming.info

            Comment

            Working...
            X