FmtBCD Range Check Error lazarus / 21-General ---------------------------------------------------------------------- lmdamiano · 2025-04-01 16:09 Hi, I've been using FmtBCD to have more than 4 decimals in my accounting software. Today I stumbled upon this error: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  uses fmtbcd; {$R *.lfm} { TForm1 }  procedure TForm1.Button1Click(Sender: TObject);var  pBCD : TBCD;begin   BCDDivide(12, CurrToBCD(1.88), pBCD);  ShowMessage('Value: ' + BCDToStr(pBCD)); end;                                I get RunError(201) range check error (tried old 32bit lazarus and new 64bit one). I have found this workaround: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   BCDDivide(CurrToBCD(12 * 10), CurrToBCD(1.88 * 10), pBCD);  However I think I'm not correctly using BCD types, I tried to search more documentation but it's very scarce. Thank you ---------------------------------------------------------------------- Thaddy · 2025-04-01 16:24 You are thinking wrong. https://en.wikipedia.org/wiki/Binary-coded_decimal The precision in Pascal depends, but is usually 4, with a 5 allowed for rounding. BCD is a fixed point float, but actually derived from a shifted integer and not a float at all. There are because of that a couple of errors in the sysutils unit where it is treated as float.(wrong) ---------------------------------------------------------------------- lmdamiano · 2025-04-01 16:50 Sorry I don't understand you answer: I'm wrong in using in BCD to handle at least 5 decimals? Is there any type which can store/manipulate decimals with more than 4 decimal? I alread know BCD was a fake integer ---------------------------------------------------------------------- AlexTP · 2025-04-01 17:02 I guess the debugging of BCDDivide() needs the debug info included, in FmtBCD unit, but this unit is in the FPC distro. Maybe FPC rebuilding is needed. I don't know yet how to compile it on Windows / how to add debug info.