Strings to floats, and back again. lazarus / 3-General ---------------------------------------------------------------------- pueblonative · 2006-06-14 19:14 var d_Total: Extended; d_SubTotal : Extended; d_SalesTax: Extended; s_TotalMessage: string; begin d_SubTotal := StrToFloat(edSubtotal.Text); d_SalesTax := StrToFloat(EdTax.Text);  if d_SalesTax >= 1.0 then     d_SalesTax := d_SalesTax / 100; d_Total := d_SubTotal + (d_SubTotal * d_SalesTax); s_TotalMessage := 'Total amount is ' + FloatToStr(d_Total); lblTotal.Text := s_TotalMessage; end; Problem is that it displays whole integers, but nothing if it's a float. ---------------------------------------------------------------------- CCRDude · 2006-06-15 12:55 You could've at least stated platform and version For FPC 2.1.1 (last daily dev source from June 4th) on Win32, I can't reprdouce your problem. Save this as FloatToStrTest.pas Code: [Select]program FloatToStrTest; uses Crt, SysUtils; var amount1, amount2, amount3: Extended; begin   amount1 := 1234567890.123456789;  // High precision number   amount2 := 1234567890123456.123;  // High mantissa digits   amount3 := 1E100;                 // High value number   WriteLn('FloatToStr test');   WriteLn('Amount1 = ' + FloatToStr(amount1));   WriteLn('Amount2 = ' + FloatToStr(amount2));   WriteLn('Amount3 = ' + FloatToStr(amount3)); end. And compile using: Quotefpc FloatToStrTest.pas Run it, and at least here it works (Win32): QuoteFloatToStr test Amount1 = 1234567890,1234568 Amount2 = 1,23456789012346E15 Amount3 = 1E100 ---------------------------------------------------------------------- pueblonative · 2006-06-15 13:34 It works, all right, the problem seems to be more of a string concatination problem on these lines: s_TotalMessage := 'Total amount is ' + FloatToStr(d_Total); lblTotal.Text := s_TotalMessage; lazarus 0.9.0 Linux fpc 2.0.1 To clarify a bit, when I do this lblTotal.Text := FloatToStr(d_Total) it works.  When I do this: s_TotalMessage := 'Total amount is ' + FloatToStr(d_Total); lblTotal.Text := s_TotalMessage; It will not display floating point numbers. ---------------------------------------------------------------------- CCRDude · 2006-06-15 15:22 Hmmm I just compiled that with a Lazarus 0.9.17 daily from June 12th (FPC 2.1.1) on Win32 and it worked even with the string thing. I'll try later on a Mac or Linux... update: Lazarus 0.9.15 on MacOSX did work as well (I added those three controls you mentioned to an empty form, and your code into FormShow; 123.12 for the subtotal, 16 for taxes, resulting in Total amount is 142.8192 displayed in the label). ---------------------------------------------------------------------- pueblonative · 2006-06-15 17:35 BTW, I can post screenshots if that is needed.  I am not making this stuff up. ---------------------------------------------------------------------- CCRDude · 2006-06-15 18:29 I wasn't thinking about that But why don't you use a newer version than 2.0.1/0.9.0? Getting the latest release is usually my first choice when finding bugs (if you're using Debian - imho the debian packages are quite old - you can use alien to convert newer rpms, something I just did on my Ubuntu installation) ---------------------------------------------------------------------- eric · 2006-06-17 13:23 As this appears to relate to currency, I suggest that you use TCurrency instead of Extended. Eric