Precision of double type lazarus / 62-General ---------------------------------------------------------------------- badmintonfan · 2021-10-02 09:01 Is there anyone know how to get more than 14 digital after decimal dot ---------------------------------------------------------------------- Warfley · 2021-10-02 09:09 Double has 53 bits of data, i.e. 53 binary digits. In base ten this is at most 53/log2(10) = 15.95 digits, I.e. not more than 15 digits (has we dont have fractional sigits) ---------------------------------------------------------------------- alpine · 2021-10-02 09:25 Quote from: Warfley on October 02, 2021, 11:09:04 amDouble has 53 bits of data, i.e. 53 binary digits. In base ten this is at most 53/log2(10) = 15.95 digits, I.e. not more than 15 digits (has we dont have fractional sigits) @badmintonfan, In addition to the above: using Extended will give you 19 significant digits (4 more) but considering the fact the point is hmm ... "floating", you should work in -1.0 .. 1.0 range to have them after it. ---------------------------------------------------------------------- MathMan · 2021-10-02 09:26 @Warfley - slight correction - the binary precision of 'double' is 54 bit, where the leading '1' is not stored in the significant (mantissa). Therefore, for correct conversion between decimal <=> binary, the required number of decimal digits is 17. 17 is > log( 2 )*54 and 17 - log( 2 )*54 > log( 2). @badmintonfan - the value you showed has exactly 17 decimal digits (see comment above). So this is all you need, and can reasonably expect when converting a 'double' value from Excel. If you explain what you actually need to achieve, we might be able to help you. Cheers, MathMan ---------------------------------------------------------------------- avk · 2021-10-02 09:51 It seems that together with the implicit bit there should be 53 bits in total? On the other hand, 2^53-1 = 9007199254740991, I counted 16 digits in it, and you? ---------------------------------------------------------------------- MathMan · 2021-10-02 10:15 Quote from: avk on October 02, 2021, 11:51:04 amIt seems that together with the implicit bit there should be 53 bits in total? On the other hand, 2^53-1 = 9007199254740991, I counted 16 digits in it, and you? avk - I stand corrected about the number of bits in the mantissa. However 17 decimal digits still holds, as otherwise you can not convert to decimal and back to bainary getting the same binary value. For that n - log( 2)*53 > log( 2 ) is required. IEEE 754 also defines it that way. Cheers, MathMan ---------------------------------------------------------------------- MarkMLl · 2021-10-02 10:27 Quote from: y.ivanov on October 02, 2021, 11:25:36 amIn addition to the above: using Extended will give you 19 significant digits (4 more) but considering the fact the point is hmm ... "floating", you should work in -1.0 .. 1.0 range to have them after it. Noting this from the manual obviously: "Note that not all float types are available on all platforms. The single float type is the only one guaranteed to be available on all platforms that have floating point support (so e.g. AVR does not have it). The double type is available on all platforms with coprocessor, and the extended type is available on all Intel x86 processors, except on the Windows 64-bit platform. More details on availability can be found in the Programmer’s Guide." MarkMLl ---------------------------------------------------------------------- wp · 2021-10-02 10:36 Quote from: badmintonfan on October 02, 2021, 11:01:41 amhow to get more than 14 digital after decimal dot When you have to ask this question you probably did something wrong in your calculations. Read about the rounding errors of floating point calculations and how to minimze them. ---------------------------------------------------------------------- MarkMLl · 2021-10-02 10:58 Quote from: wp on October 02, 2021, 12:36:09 pmWhen you have to ask this question you probably did something wrong in your calculations. Or are about to :-) MarkMLl ---------------------------------------------------------------------- winni · 2021-10-02 11:09 Quote from: badmintonfan on October 02, 2021, 11:01:41 amIs there anyone know how to get more than 14 digital after decimal dot Hi! Use the BCDunit: https://wiki.lazarus.freepascal.org/BcdUnit Winni ---------------------------------------------------------------------- alpine · 2021-10-02 11:12 Quote from: MarkMLl on October 02, 2021, 12:27:50 pmNoting this from the manual obviously: "Note that not all float types are available on all platforms. ..." Right. But the OP is working with Excel. Guess the platform I'm trying to give him something to think about (the range) with a hope he'll realize what wp wrote in the latter post. ---------------------------------------------------------------------- avk · 2021-10-02 11:40 @MathMan sorry, the second sentence was mainly about Quote from: Warfley on October 02, 2021, 11:09:04 am... I.e. not more than 15 digits (has we dont have fractional sigits) ---------------------------------------------------------------------- winni · 2021-10-02 11:44 Quote from: y.ivanov on October 02, 2021, 01:12:53 pm But the OP is working with Excel. Guess the platform Linux with wine ..... ---------------------------------------------------------------------- MarkMLl · 2021-10-02 11:51 Quote from: y.ivanov on October 02, 2021, 01:12:53 pmBut the OP is working with Excel. Guess the platform Most people who get here will have arrived via Google, so are more than likely to miss non-quoted context. Besides: "Microsoft enabled Word, PowerPoint, Outlook, OneNote, and Excel as ARM64 apps. Other Office apps will still run in x64 emulation mode." https://www.windowscentral.com/office-windows-11-arm-starts- rolling-out-insiders MarkMLl ---------------------------------------------------------------------- Paolo · 2021-10-02 12:04 I could be wrong, but double sboukd be 64bit, where: 1 sign 11 exponent Remains 52 for mantissa. Missed somthing ? ---------------------------------------------------------------------- winni · 2021-10-02 12:17 Hi! For details of IEEE 754 look at https://en.wikipedia.org/wiki/IEEE_754 Winni ---------------------------------------------------------------------- alpine · 2021-10-02 13:12 Quote from: MarkMLl on October 02, 2021, 01:51:49 pmQuote from: y.ivanov on October 02, 2021, 01:12:53 pmBut the OP is working with Excel. Guess the platform Most people who get here will have arrived via Google, so are more than likely to miss non-quoted context. (With respect)  You're definitely not arrived from there, but you also missed my last sentence in that same post, though Quote from: winni on October 02, 2021, 01:44:19 pmQuote from: y.ivanov on October 02, 2021, 01:12:53 pm But the OP is working with Excel. Guess the platform Linux with wine ..... Yeah, most probably ... ---------------------------------------------------------------------- Paolo · 2021-10-02 13:20 The standard seems confirming that 52 bit are used for the fractional part, neither 53 or 54. Right ? ---------------------------------------------------------------------- MarkMLl · 2021-10-02 13:46 Quote from: y.ivanov on October 02, 2021, 03:12:36 pm(With respect)  You're definitely not arrived from there, but you also missed my last sentence in that same post, though Didn't. MarkMLl ---------------------------------------------------------------------- Warfley · 2021-10-02 14:22 Quote from: Paolo on October 02, 2021, 03:20:48 pmThe standard seems confirming that 52 bit are used for the fractional part, neither 53 or 54. Right ? The first 1 is assumed implicitly through the exponent (as this can be seen as leadingzeroes) thats why you have 53 bits effectively ---------------------------------------------------------------------- Paolo · 2021-10-02 14:33 This is clear. I am just referring to the physical bit available that are 52.