6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Apr 27, 2024 1:46 pm

All times are UTC




Post new topic Reply to topic  [ 82 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6
Author Message
PostPosted: Mon Nov 06, 2023 8:03 pm 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1398
Location: Scotland
BruceRMcF wrote:
One approach is to look to a fractional number format that would be less work to implement, such as a 3+1 byte rational number format, with 24 bit numerator and 8 bit denominator.


Or simply look at the documents for IEEE 754 floating point and write an implementation from scratch...

-Gordon
(No emphasis on the word simply ;-)

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 07, 2023 12:13 pm 
Offline

Joined: Wed Aug 21, 2019 6:10 pm
Posts: 217
drogon wrote:
BruceRMcF wrote:
One approach is to look to a fractional number format that would be less work to implement, such as a 3+1 byte rational number format, with 24 bit numerator and 8 bit denominator.


Or simply look at the documents for IEEE 754 floating point and write an implementation from scratch...

-Gordon
(No emphasis on the word simply ;-)


Or find a C reference implementation like SoftFloat -- http://www.jhauser.us/arithmetic/SoftFloat.html -- and port it -- but porting from C to 6502 assembly language does not appear to be enough like having fun for anyone to have done so yet.


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 08, 2023 4:15 am 
Offline

Joined: Thu Mar 12, 2020 10:04 pm
Posts: 690
Location: North Tejas
drogon wrote:
BruceRMcF wrote:
One approach is to look to a fractional number format that would be less work to implement, such as a 3+1 byte rational number format, with 24 bit numerator and 8 bit denominator.


Or simply look at the documents for IEEE 754 floating point and write an implementation from scratch...


Been there, still trying to do that...


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 08, 2023 4:17 am 
Offline

Joined: Thu Mar 12, 2020 10:04 pm
Posts: 690
Location: North Tejas
BruceRMcF wrote:
Or find a C reference implementation like SoftFloat -- http://www.jhauser.us/arithmetic/SoftFloat.html -- and port it -- but porting from C to 6502 assembly language does not appear to be enough like having fun for anyone to have done so yet.


Someone could compile it and hand optimize the generated code?


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 08, 2023 5:38 pm 
Offline

Joined: Wed Aug 21, 2019 6:10 pm
Posts: 217
BillG wrote:
BruceRMcF wrote:
Or find a C reference implementation like SoftFloat -- http://www.jhauser.us/arithmetic/SoftFloat.html -- and port it -- but porting from C to 6502 assembly language does not appear to be enough like having fun for anyone to have done so yet.


Someone could compile it and hand optimize the generated code?


An advantage of that approach is that if someone gets it to compile for a 6502 target and then hand-optimizes it so it is "small enough and fast enough" for their purposes, others could pick up the ball and hand optimize it further.

My guess is it would be a grind, but if someone finds that kind of grind with 6502 assembly language to be a good way to escape from the turmoil of a busy week, maybe.


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 08, 2023 6:44 pm 
Offline

Joined: Fri Jul 09, 2021 10:12 pm
Posts: 741
I'm not sure that standard IEEE formats are the right choice for a 6502. Splitting the exponent over two bytes is very awkward, and I think there's a reasonably good argument for storing the significand in signed two's complement form.

My own floating point routines use a similar format to Acorn's, but narrower, and I think it helps efficiency compared with IEEE float formats.

I write things like this from scratch partly because I enjoy (and learn from) reinventing wheels, but also because I don't want to be encumbered by any licensing requirements, even for free software, such as preserving credit notices and so on - I don't mind giving credit in principle, but I don't have time to be legally obliged to do so.

I also don't want anyone to feel barred from using anything I've shared for these reasons, so I explicitly use the Unlicense in general.


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 08, 2023 9:45 pm 
Offline

Joined: Sun Feb 22, 2004 9:01 pm
Posts: 78
Hey, if anybody wants 8+32 floating point arithmetic for the PDP11, you're welcome to use it. :)

I've found that the really nice thing about 5-byte floating point is the ability to also hold an integer over the whole range of values, encoded with the exponent being zero.

In any floating format, a floating zero is an exception, and is usually coded exp=00,man=00,00...., so just extend that and if the exponent is zero, the mantissa is an integer. 5-byte floats allows you to hold a full 32-bit integer as 00,xxxxxxxx. Other sizes, such as 4-byte floats, don't give you enough "space" in the bits.

_________________
--
JGH - http://mdfs.net


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 82 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6

All times are UTC


Who is online

Users browsing this forum: No registered users and 21 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: