08 July 2021, 14:40 | #21 |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
|
13 July 2021, 11:17 | #22 |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
So, something like this:
Code:
// to do, this afternoon constexpr FFP composeffp(const LONG mantissa, const LONG exponent) { return exponent; } constexpr FFP r(const char * s) { FFP n = 0; LONG mantissa = 0L; LONG exponent = 0L; bool negativeMantissa = false; bool negativeExponent = false; bool parsingExponent = false; for (const char * p = s; *p; *p++) { const char c = *p; if (!parsingExponent) { if (c >= '0' && c <= '9') mantissa = mantissa * 10 + (c - '0'); else if (c == '-') negativeMantissa = true; else if (c == 'e' || c == 'E') parsingExponent = TRUE; } else { if (c >= '0' && c <= '9') exponent = exponent * 10 + (c - '0'); else if (c == '-') negativeExponent = TRUE; } } if (negativeMantissa) mantissa = -mantissa; if (negativeExponent) exponent = -exponent; return composeffp(mantissa, exponent); } |
13 July 2021, 14:15 | #23 |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
I have also just found this:
https://github.com/xroche/ieee754toy Which looks like it does a more advanced version of what I'm trying to do. I'm still trying to understand it properly, it uses more things that are new to me, like function templates. |
13 July 2021, 18:55 | #24 |
Registered User
Join Date: Jun 2020
Location: Druidia
Posts: 389
|
For what it's worth I updated my code so it can generate instances of my ffp class from native floats at compile time and vice versa.
I didn't port the 68000 assembler versions, which seems to be what alkis has done. Those versions are pretty hard to follow. Instead I wrote simple to follow C versions. That doesn't help you with your string parser but my versions are maybe useful to others. https://github.com/rjobling/ffloat |
13 July 2021, 19:12 | #25 | |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
Quote:
|
|
13 July 2021, 19:30 | #26 |
Registered User
Join Date: Jun 2020
Location: Druidia
Posts: 389
|
As far as I'm aware all the versions we've posted do the best job possible to translate from IEEE to FFP, and a perfect job translating from FFP to IEEE.
|
13 July 2021, 19:53 | #27 | |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
Quote:
In any case, there can be no such thing as a perfect job of translating between the formats, as they have different ranges and precisions. Not every number that can be exactly represented by IEEE be exactly represented in FFP, and visa versa. Now, of course, loads of adenoids will come along to explain that floating point numbers should always be treated as approximations and never compared directly, etc. etc., but I don't care about that, I don't want one part of my code base converting a string to one number and another part converting the exact same string to a slightly different number. |
|
13 July 2021, 20:39 | #28 | |
Registered User
Join Date: Jun 2020
Location: Druidia
Posts: 389
|
Quote:
That's incorrect. All valid FFP numbers have an IEEE equivalent. Here is the original code I had copied which has some comments. https://github.com/ggnkua/Atari_ST_S...FFP/FFPIEEE.SA You can also read the FFP format description in the Amiga libs documentation. http://amigadev.elowar.com/read/ADCD.../node047D.html |
|
13 July 2021, 21:19 | #29 |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
You've just made up my mind. I have better, more interesting things to do than develop for the Amiga.
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Generating an accurate Paula period table | 8bitbubsy | Coders. General | 55 | 07 September 2020 21:04 |
Wanted: C source for converting gcc (linux) float to FFP | alkis | Coders. C/C++ | 5 | 16 August 2020 02:39 |
Integers vs floats (FFP/Sing/Doub) + printf() | guy lateur | Coders. Asm / Hardware | 63 | 18 July 2017 17:57 |
WinUAELoader: generating single game .uae? | Telegattone | support.WinUAE | 1 | 27 December 2016 12:28 |
Software for generating screenshots and videos | Edi (FZ2D) | Retrogaming General Discussion | 5 | 08 April 2010 23:34 |
|
|