is this a bug? For H in [a,b,c] lazarus / 21-General ---------------------------------------------------------------------- mtanner · 2022-04-07 11:09 When I code var H:double; For H in [0.001, (1/2), (7/10), 0.999] do ShowMessage(FloatToStr(H)); then the numbers displayed are as you would expect: 0.001, 0.5, 0.7, 0.999 But when I code For H in [0.001, 0.5, 0.7, 0.999] then ShowMessage(FloatToStr(H)); I see : 0.001, Nan, 0.7, 0.999 ---------------------------------------------------------------------- howardpc · 2022-04-07 11:29 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 program Project1; {$mode objfpc}{$H+} uses  SysUtils;   var    arr: array of Double = (0.001, 1/2, 7/10, 0.999);    arr2: array of Double = (0.001, 0.5, 0.7, 0.999);    H: Double; begin for H in arr do   WriteLn(FloatToStr(H));  for H in arr2 do   WriteLn(FloatToStr(H)); ReadLn;end.The above runs as expected. I think your [] syntax is not interpreted as you expect. Do you use {$mode Delphi}? ---------------------------------------------------------------------- mtanner · 2022-04-07 11:40 When I code var Hlist:array of double = (0.001, 0.5.0.7.0.999); For H in HList do ShowMessage(FloatToStr(H)); then the numbers display as expected. But with For H in [0.001, 0.5, 0.7, 0.999] do ShowMessage(FloatToStr(H)); then the 0.5 comes out as Nan. The syntax For H in (0.001,0.5,0.7,0.999) do ... is not accepted. I am not using {$mode Delphi} as far as I am aware, defintely not explicitly. I am just very puzzled. Why should 0.5 give Nan while 0.7 gives 0.7? ---------------------------------------------------------------------- Zvoni · 2022-04-07 11:56 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 program Project1;Uses SysUtils;Var  H:Double;begin  For H in [0.001, 0.5, 0.7, 0.999] Do Writeln(H.ToString);end. Result (German locale): 0,001 0 0,7 0,999 There is something rotten in Denmark...... ---------------------------------------------------------------------- Handoko · 2022-04-07 12:20 The NAN issue happened on me too, I guess because I'm using Lazarus and doing it in GUI (don't use Writeln). ---------------------------------------------------------------------- Zvoni · 2022-04-07 12:45 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 program Project1;Uses SysUtils;Var  H:Double;  i:Integer;  arr2: array of Double = (0.001, 0.5, 0.7, 0.999);begin  For H In arr2 Do Writeln(H.ToString);    For i:=Low(arr2) To High(arr2) Do Writeln(arr2[i].ToString);end.Returns: 0,001 0,5 0,7 0,999 0,001 0,5 0,7 0,999 Yep, seems to be the In-operator in combination with a "direct" Array (Not in a variable) ---------------------------------------------------------------------- AlexTP · 2022-04-07 13:33 Reported to GitLab, https://gitlab.com/freepascal.org/fpc/source/-/issues/39656 ---------------------------------------------------------------------- Zvoni · 2022-04-07 14:01 It's getting weird.... Replace the Double-Type with "Extended" For the 0.5 i'm getting 3,85284689429794E-4942 when i Writeln it..... ---------------------------------------------------------------------- PascalDragon · 2022-04-08 15:47 Fixed in 815734c47a4afe7d07083757f9ed6df233762abb. ---------------------------------------------------------------------- mtanner · 2022-04-09 07:25 Bit of a shame to have issues line this with the "in" operator. I developed my (sometimes bad) Pascal coding habits with the original Turbo Pascal, which (I think) did not have the IN operator. Having recently stumbled across an article on the net about FPC features I discovered the in operator, and have found it extremely useful.  Like discovering a great new DIY tool, only to find it breaks very easily when you actually use it. ---------------------------------------------------------------------- AlexTP · 2022-04-09 07:28 When you see bugs like these, just report them on the forum. Devs missed it. ---------------------------------------------------------------------- marcov · 2022-04-09 09:45 Quote from: PascalDragon on April 08, 2022, 05:47:31 pmFixed in 815734c47a4afe7d07083757f9ed6df233762abb. Merged? ---------------------------------------------------------------------- PascalDragon · 2022-04-09 13:13 Quote from: mtanner on April 09, 2022, 09:25:41 amBit of a shame to have issues line this with the "in" operator. I developed my (sometimes bad) Pascal coding habits with the original Turbo Pascal, which (I think) did not have the IN operator. Having recently stumbled across an article on the net about FPC features I discovered the in operator, and have found it extremely useful.  Like discovering a great new DIY tool, only to find it breaks very easily when you actually use it. You are mixing two different things here. Pascal has an in-operator since it has sets which it has from its beginnings. What was used here is not the in-operator, but the for … in-loop. These are totally different things. Also this functionality didn't break, because the ability to use an literal array as the expression to be iterated on the right side of the in was only added with 3.2.0. And there this use case simply wasn't handled, because literal arrays were mainly tested with assignments and concatenation, but not with for … in, thus this issue simply slipped past and no preexisting code broke with this. Quote from: AlexTP on April 09, 2022, 09:28:20 amWhen you see bugs like these, just report them on the forum. Devs missed it. No, if you see bugs like these, then report them on the issue tracker, not the forum. Also this issue was known for a longer time already, just as always the point is to find the time and yesterday I already wanted to tackle the other bug with the string array and there just happened to be this one as well (which pointed me in the right direction to solve this). Quote from: marcov on April 09, 2022, 11:45:58 amQuote from: PascalDragon on April 08, 2022, 05:47:31 pmFixed in 815734c47a4afe7d07083757f9ed6df233762abb. Merged? Now it is. I wanted to wait for the testsuite results for other platforms.