06 March 2014, 14:30 | #1 | |
Registered User
Join Date: Aug 2008
Location: Salisbury
Posts: 744
|
Working out a decimal percentage for display
Me again!
I'm trying to work out the percentage difference between two numbers so that it can be displayed as, for example, +%040 on screen. I've already got a the decimal conversion, the problem is working out the actual value. I tried the following.. Quote:
It also needs to deal with the calculation the other way, i.e. show a negative percentage. Any help would be awesome. |
|
06 March 2014, 15:52 | #2 |
Unregistered User
Join Date: Sep 2012
Location: Copenhagen / DK
Age: 43
Posts: 4,190
|
If you want two decimals, you could do the following in pseudo-code using integer math:
If Num1>Num2 Result = Num1*100 / Num2 - 100 else Result = -(Num2*100 / Num1 - 100) Last edited by demolition; 06 March 2014 at 15:55. Reason: Parenthesis error |
06 March 2014, 16:00 | #3 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
|
move #original value,d1
move #new value, d0 sub d1, d0 muls #100,d0 divs d1,d0 if you do that with your example above, d0 will now be -25 (90 is 120-25%). |
06 March 2014, 16:04 | #4 |
Registered User
Join Date: Aug 2008
Location: Salisbury
Posts: 744
|
|
06 March 2014, 16:04 | #5 |
Unregistered User
Join Date: Sep 2012
Location: Copenhagen / DK
Age: 43
Posts: 4,190
|
|
06 March 2014, 16:07 | #6 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
|
|
07 March 2014, 09:49 | #7 |
Registered User
Join Date: Aug 2008
Location: Salisbury
Posts: 744
|
Well this has been a learning experience, only just realised there is a MULS and MULU! Signed and unsigned. I really need to read the 68000 manual again!
All good now, got it working |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Better display | Ronnie_ASA | support.WinUAE | 1 | 01 March 2014 19:50 |
External Disk Drive working and not working | fc.studio | support.Hardware | 12 | 10 August 2009 03:04 |
floppy df0 working / not working | Dave_wb | support.Hardware | 3 | 07 January 2009 09:11 |
Hex to Decimal | -Rob- | Coders. General | 8 | 21 June 2006 19:22 |
Display problem | abelthorne | support.WinUAE | 1 | 25 November 2003 13:25 |
|
|