Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Fraction adding / subtracting algorithm

Author
Message
SH4773R
16
Years of Service
User Offline
Joined: 18th Jan 2010
Location: AMERICA!!!
Posted: 2nd Sep 2010 05:39 Edited at: 2nd Sep 2010 05:47
I made this simple algorithm i made for fun and for learning and i thought i'd share it w/ u guys!

Variable explanations:


Main Algorithm:


Example program (dbpro)



leave any comments or bugs in a comment, i love feed back!

Who the hell is General Failure? And why is he trying to read my hard disk?

My software never has bugs. It just develops random features.
SH4773R
16
Years of Service
User Offline
Joined: 18th Jan 2010
Location: AMERICA!!!
Posted: 2nd Sep 2010 06:58
Wow 7 views and no comments

Who the hell is General Failure? And why is he trying to read my hard disk?

My software never has bugs. It just develops random features.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Sep 2010 13:39 Edited at: 2nd Sep 2010 18:11
Quote: "Wow 7 views and no comments"


It doesn't work. Did you test it?

If you try 1/2+1/2 your program gives 4. I think the answer ought to be 1.

Edit Why did you post this? You've already started a thread on the same topic with the same mistake.
SH4773R
16
Years of Service
User Offline
Joined: 18th Jan 2010
Location: AMERICA!!!
Posted: 3rd Sep 2010 05:05
i posted it because it is working there was a problum with variable size (for my benchmark program using same algortium)

im not shure why its not working for u it works for me :/

are u getting a 2 value output?

ps remember its not reduced

Who the hell is General Failure? And why is he trying to read my hard disk?

My software never has bugs. It just develops random features.
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 3rd Sep 2010 12:06 Edited at: 3rd Sep 2010 12:20
Quote: "If you try 1/2+1/2 your program gives 4. I think the answer ought to be 1."

Actually GG it gives:
4
-
4

It's giving numerator and denominator on seperate lines (4/4=1)... not very user friendly.

Try this:


EDIT: Forgot to make the results look nice!

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 5th Sep 2010 22:45
Quote: "ps remember its not reduced"


Quote: "It's giving numerator and denominator on seperate lines (4/4=1)... not very user friendly."


Oops! Sorry! I misunderstood.
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 5th Sep 2010 23:12
but... proper fractions are reduced, so technically this doesn't adhere to mathematical standards.

If you wanted to make a proper function, I'd do this:
make a function that "returns" an array called "prime_factorization"
make a function that finds the LCM of two numbers.
make a function that "returns" two numbers "given" two arrays (of prime numbers only) called "reduce" (reduces (2*5*7*3*3)/(3*5*2*2*2) to (7*3)/(2*2) to 21/4)

and then all the fraction adding and subtracting should follow.

Login to post a reply

Server time is: 2026-07-23 04:38:15
Your offset time is: 2026-07-23 04:38:15