Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
June 16, 2024, 03:39:04 03:39


Login with username, password and session length


Pages: [1]
Print
Author Topic: Division in picbasic pro  (Read 3680 times)
0 Members and 1 Guest are viewing this topic.
silvabelbr
Guest
« on: December 10, 2007, 12:09:01 00:09 »

Is the picbasic pro accepts the decimal points specially in division (ex: 25.6/2.5)
if not what can i do?Huh?

thanx in advance
Logged
frasenci
Translator
Active Member
***
Offline Offline

Posts: 171

Thank You
-Given: 142
-Receive: 84


« Reply #1 on: December 10, 2007, 02:29:47 02:29 »

As far as I know , NO, PBP will not handle decimals. ( V 2.47 ).
You have to use integers only , and always remember that reminders are cut off.
For your example : 25.6/2.5 yo have to amplify by 10 , so you do 256/25 but the outcome will be INT 10 , decimal part is lost.
You will have to code an mathematical algorithm to recover the 0,24 ( decimal part ) and decide what to do . 256 / 25 = 10 x 25 + 6
I think you can google around for this kind of algorithm, there are quiet a few out there.
greetings
Logged
ero
Junior Member
**
Offline Offline

Posts: 43

Thank You
-Given: 12
-Receive: 27


« Reply #2 on: December 10, 2007, 06:23:59 06:23 »

It is easy to obtain decimal points.
25.6 x 1000=25600
2,5 x 10= 25
(25,6 x 1000)/(2,5 x10)  (we have multiplied upper part by 100)
25600/25 = 1024
decimal = 1024/100= 10
fraction= 1024//100=24  (this is the MOD process)

Ero
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC