Best way to get the square root of a 16/32 bit unsigned integer


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563

    Default Best way to get the square root of a 16/32 bit unsigned integer

    Hi All,

    In one of my implementation of a true RMS voltmeter I used the Mchip technical bulletin TB040 to find the square root of a 16bit number. I was using the ADC in 8bit on a PIC18. I would like the pros to shed some light on a better way dealing with longs sqrt.

    P.S. = Perhaps a better way to measure AC RMS
    Last edited by sougata; - 17th March 2008 at 19:02. Reason: Might be that should be the question
    Regards

    Sougata

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sougata View Post
    find the square root of a 16bit number
    Since it's only a 16 bit number, maybe you'd be best off using a lookup table. After all, there are only 255 integer numbers of squares inside of 16 bits...

    EDIT: Whoops! Just saw that the title said 16/32 bit sqrt instead of 16 bit only.

    But...I'd say, same thing still applies. Could easily get the sqrt of the upper 16 bits of the 32 bits using a lookup table. Then depending on the accuracy required, interpolate the lower 16 bits.
    Last edited by skimask; - 17th March 2008 at 19:14.

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default

    Hi, Sougata

    I do not understand your question ...

    TB 040 ALSO deals with 32 bits ...

    Code:
    ; *******************************************************************
    Title"16/32 bit Integer Square Root"
    ; *******************************************************************
    ; *******************************************************************
    ; *** ***
    ; *** Author: Ross Fosler ***
    ; *** Applications Engineer ***
    ; *** Microchip Technology Inc. ***
    ; *** ***
    ; *** Program:sqrt.asm ***
    ; *** This module contains code to perform fast integer ***
    ; *** square root functions on either 16 or 32 bit ***
    ; *** values. ***
    ; *** ***
    ; *** Last Rev:August 10, 2000 ***
    ; *** Ver 1.00 ***
    ; *** ***
    ; *******************************************************************
    ????

    Are you looking for faster than that ???

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default Yes a faster one

    Hi Alain,

    I am actually looking for a faster and better way to do it. Cause my system measures 16 channels and does a whole lot of logging housekeeping stuff.
    Regards

    Sougata

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. How to receive stream of bytes using PIC USART
    By unifoxz in forum mel PIC BASIC Pro
    Replies: 34
    Last Post: - 20th June 2009, 10:38
  3. 32 bit square root
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 6th May 2009, 03:37
  4. PICBasic newbie problem
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 12th February 2008, 00:55
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

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