# PICMicrocontollerMathLibraryMethods

• I very much appreciate your site. I am just learning about microcontrollers, and this is certainly a panacea for one like me. Your site is extremely informative, well-organized, and lean.

A++

Allasso+
• http://www.microchip.com/10/appnote/category/library/ Go to Microchip for source code for (PIC assembly language) math libraries. The app notes explain several collections of routines: fixed-point math, floating-point math, and IEEE 754 Compliant Floating Point Routines.

Questions:

• Lee Kok Zhi asks: " Im using PIC16F877. How can I do 16-bits square root with it? I realize that all the square root routine available at here is only for 17Cxx or 18cxx."
Hi

Using PIC16F877 - I have an input value of up to 65535 (from an A/D convereter) and want to scale it by a variable factor to give an answer from 0.0001 up to 99999, with 1 in 65535 resolution. (The value will be displayed on a 5 digit 7 segment display, with + or - sign)

I'm struggling.. any bright folk have a suggestion?

Graham

James Newton replies: So 0 will be .0001? and 65535 will be 99999? First, convert to integer: Multiply your beginning and ending output by 10000. 0.0001 * 10000 = 1. 99999 * 10000 = 999,990,000. Now, subtract the starting value from the ending value to find the output range. 999,990,000 - 1 = 999989999. Now for any input value, you will multiply it by 999989999/65535 = 15258.869291218432898451209277485 and then add 1. You will display the first 5 digits of this answer, then a period, then the last 4 digits.

For example, if the input is 0, the answer will be 0 * 15258.869291218432898451209277485 + 1 = 1. Please note that this is actually 000,000,001 which will be displayed as 00000.0001. If the input is 65535, the answer will be 65535 * 15258.869291218432898451209277485 + 1 = 999990000 which will be displayed as 99999.0000

Now, I have no idea how the heck you are going to get that kind of precision out of a PIC. The best I can show you is the input * 15258.9 + 1. with that, the top end is 99999.2012. The code to do the multiplication is at
http://www.piclist.com/cgi-bin/constdivmul.exe?Acc=ACC&Bits=16&endian=little&Const=15258.9&ConstErr=0&Temp=TEMP&cpu=pic16

Increment the result by one:
http://www.piclist.com/techref/microchip/math/incdec/32bitwz.htm

Convert to decimal ASCII:
+

+

louis frias asks: Hi every one I am looking for 48 bit x 48 bit "signed integer divide" I see in the your math libraries 48/24 bit code but not 48/48. If there is non ...Is there any one willing to write/modify any existing signed integer divides such as the 32/32 signed divide given in the microchip math library Handbook ??????????????? Please email to me loui@g2a.net at your earliest convenience Louis Frias

• TakeThisOuTshenyeepang at -Remove-hotmail.com asks: " I have a series of 1 and 0, how can I apply quarter wave symmetry to mirror this series? eg. 010001110111111 (quarter)" +
See Bit Math Method Reverse bit order in a byte

• Hernan J Freschi asks: " How do I use numbers bigger than 255? I mean, I have a 32-bit pentium processor, which counts over 4,294,967,296..."
• TakeThisOuThjf at -Remove-hjf.com.ar asks: " How do I work with numbers bigger than 255?! They didn't teach me that at my university!"
Use a second register. The first does 0 to 255, if the second is 0, but it represents 256 to 511 if the second register is 1 and so on. The result is 256 times 256 different possible values or 65536 total values. This can continue with three or more registers untill you reach a point where all the memory locations are used or you have a big enough number range.

Archive:

Code:

 file: /Techref/microchip/math/index.htm, 16KB, , updated: 2017/5/20 20:52, local time: 2018/10/19 07:35, TOP NEW HELP FIND:  54.225.26.44:LOG IN

 ©2018 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?Please DO link to this page! Digg it! / MAKE! /  PIC Microcontoller, PIC Math Methods

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.

Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
 Did you find what you needed? "random" "No. I'm looking for: " "No. Take me to the search page." "No. Take me to the top so I can drill down by catagory" "No. I'm willing to pay for help, please refer me to a qualified consultant" "No. But I'm interested. me at when this page is expanded."

 PICList 2018 contributors: o List host: MIT, Site host massmind.org, Top posters @20181019 RussellMc, Van Horn, David, Sean Breheny, David C Brown, Isaac M. Bavaresco, Neil, Bob Blick, John Gardner, Harold Hallikainen, Denny Esterline, * Page Editors: James Newton, David Cary, and YOU! * Roman Black of Black Robotics donates from sales of Linistep stepper controller kits. * Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters. * Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated! * Contributors: Richard Seriani, Sr.

.