Populate sequence containing NaNChecking if a double (or float) is NaN in C++How do you test to see if a double is equal to NaN?What is the rationale for all comparisons returning false for IEEE754 NaN values?How do you check that a number is NaN in JavaScript?Is it possible to set a number to NaN or infinity?How to turn NaN from parseInt into 0 for an empty string?Why is NaN not equal to NaN?Removing nan values from an arrayHow to check if any value is NaN in a Pandas DataFrameWhat is the difference between (NaN != NaN) and (NaN !== NaN)?

Building a list of products from the elements in another list

How can I close a gap between my fence and my neighbor's that's on his side of the property line?

Why do only some White Walkers shatter into ice chips?

Which module had more 'comfort' in terms of living space, the Lunar Module or the Command module?

What was the design of the Macintosh II's MMU replacement?

Why wasn't the Night King naked in S08E03?

How can I support myself financially as a 17 year old with a loan?

Purpose of のは in this sentence?

Does a card have a keyword if it has the same effect as said keyword?

I need a disease

Position of past participle and extent of the Verbklammer

Getting a W on your transcript for grad school applications

I drew a randomly colored grid of points with tikz, how do I force it to remember the first grid from then on?

Why are prions in animal diets not destroyed by the digestive system?

What are the differences between credential stuffing and password spraying?

Can my company stop me from working overtime?

Prove that the limit exists or does not exist

Missing Piece of Pie - Can you find it?

What matters more when it comes to book covers? Is it ‘professional quality’ or relevancy?

Would Hubble Space Telescope improve black hole image observed by EHT if it joined array of telesopes?

Why didn't the check-in agent recognize my long term visa?

Can there be a single technologically advanced nation, in a continent full of non-technologically advanced nations?

Where can I go to avoid planes overhead?

Using a microphone from the 1930s



Populate sequence containing NaN


Checking if a double (or float) is NaN in C++How do you test to see if a double is equal to NaN?What is the rationale for all comparisons returning false for IEEE754 NaN values?How do you check that a number is NaN in JavaScript?Is it possible to set a number to NaN or infinity?How to turn NaN from parseInt into 0 for an empty string?Why is NaN not equal to NaN?Removing nan values from an arrayHow to check if any value is NaN in a Pandas DataFrameWhat is the difference between (NaN != NaN) and (NaN !== NaN)?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















Nim language question here. I want to read a series of floats from stdin (this example: 7, 1, 4, 4, nan, 4) and store it in a seq[float] type. The input may contain NaNs. But I fail to integrate such outliers.



My code:



var
line: TaintedString
timeSeries: seq[float]

while readline(stdin, line) != false:
echo timeSeries
timeSeries.add(parseFloat(line))


The output:



@[]
@[7.0]
@[7.0, 1.0]
@[7.0, 1.0, 4.0]
@[7.0, 1.0, 4.0, 4.0]
@[7.0, 1.0, 4.0, 4.0, nan]
@[nan, nan, nan, nan, nan, nan]


Facing the first NaN, Nim renders all inputs as NaNs. But I want this (last line of output):



@[7.0, 1.0, 4.0, 4.0, nan, 4.0]


How do I solve it correctly in Nim? Documentation says NaNs are supported…










share|improve this question






















  • What platform are you on and what back-end compiler are you using?

    – Anthon
    Mar 23 at 6:39











  • I am using nim 0.19.4 on Linux/i386, backend compiler is gcc and I have the same effect with -d:release switch. Sorry, I omitted the import statement in above snippet.

    – smartmic
    Mar 23 at 8:32


















0















Nim language question here. I want to read a series of floats from stdin (this example: 7, 1, 4, 4, nan, 4) and store it in a seq[float] type. The input may contain NaNs. But I fail to integrate such outliers.



My code:



var
line: TaintedString
timeSeries: seq[float]

while readline(stdin, line) != false:
echo timeSeries
timeSeries.add(parseFloat(line))


The output:



@[]
@[7.0]
@[7.0, 1.0]
@[7.0, 1.0, 4.0]
@[7.0, 1.0, 4.0, 4.0]
@[7.0, 1.0, 4.0, 4.0, nan]
@[nan, nan, nan, nan, nan, nan]


Facing the first NaN, Nim renders all inputs as NaNs. But I want this (last line of output):



@[7.0, 1.0, 4.0, 4.0, nan, 4.0]


How do I solve it correctly in Nim? Documentation says NaNs are supported…










share|improve this question






















  • What platform are you on and what back-end compiler are you using?

    – Anthon
    Mar 23 at 6:39











  • I am using nim 0.19.4 on Linux/i386, backend compiler is gcc and I have the same effect with -d:release switch. Sorry, I omitted the import statement in above snippet.

    – smartmic
    Mar 23 at 8:32














0












0








0








Nim language question here. I want to read a series of floats from stdin (this example: 7, 1, 4, 4, nan, 4) and store it in a seq[float] type. The input may contain NaNs. But I fail to integrate such outliers.



My code:



var
line: TaintedString
timeSeries: seq[float]

while readline(stdin, line) != false:
echo timeSeries
timeSeries.add(parseFloat(line))


The output:



@[]
@[7.0]
@[7.0, 1.0]
@[7.0, 1.0, 4.0]
@[7.0, 1.0, 4.0, 4.0]
@[7.0, 1.0, 4.0, 4.0, nan]
@[nan, nan, nan, nan, nan, nan]


Facing the first NaN, Nim renders all inputs as NaNs. But I want this (last line of output):



@[7.0, 1.0, 4.0, 4.0, nan, 4.0]


How do I solve it correctly in Nim? Documentation says NaNs are supported…










share|improve this question














Nim language question here. I want to read a series of floats from stdin (this example: 7, 1, 4, 4, nan, 4) and store it in a seq[float] type. The input may contain NaNs. But I fail to integrate such outliers.



My code:



var
line: TaintedString
timeSeries: seq[float]

while readline(stdin, line) != false:
echo timeSeries
timeSeries.add(parseFloat(line))


The output:



@[]
@[7.0]
@[7.0, 1.0]
@[7.0, 1.0, 4.0]
@[7.0, 1.0, 4.0, 4.0]
@[7.0, 1.0, 4.0, 4.0, nan]
@[nan, nan, nan, nan, nan, nan]


Facing the first NaN, Nim renders all inputs as NaNs. But I want this (last line of output):



@[7.0, 1.0, 4.0, 4.0, nan, 4.0]


How do I solve it correctly in Nim? Documentation says NaNs are supported…







sequence nan nim






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 22 at 22:33









smartmicsmartmic

333310




333310












  • What platform are you on and what back-end compiler are you using?

    – Anthon
    Mar 23 at 6:39











  • I am using nim 0.19.4 on Linux/i386, backend compiler is gcc and I have the same effect with -d:release switch. Sorry, I omitted the import statement in above snippet.

    – smartmic
    Mar 23 at 8:32


















  • What platform are you on and what back-end compiler are you using?

    – Anthon
    Mar 23 at 6:39











  • I am using nim 0.19.4 on Linux/i386, backend compiler is gcc and I have the same effect with -d:release switch. Sorry, I omitted the import statement in above snippet.

    – smartmic
    Mar 23 at 8:32

















What platform are you on and what back-end compiler are you using?

– Anthon
Mar 23 at 6:39





What platform are you on and what back-end compiler are you using?

– Anthon
Mar 23 at 6:39













I am using nim 0.19.4 on Linux/i386, backend compiler is gcc and I have the same effect with -d:release switch. Sorry, I omitted the import statement in above snippet.

– smartmic
Mar 23 at 8:32






I am using nim 0.19.4 on Linux/i386, backend compiler is gcc and I have the same effect with -d:release switch. Sorry, I omitted the import statement in above snippet.

– smartmic
Mar 23 at 8:32













1 Answer
1






active

oldest

votes


















1














Since you echo timeSeries before you add the next number, the input of the last line with 4 causes the @[7.0, 1.0, 4.0, 4.0, nan] and it is guesswork what you did after that to get the final output line. Although I doubt there is a valid reason for anything to set every value in the sequence to NaN, it might be that what your input triggered a bug.



I have not been able to reproduce your output
with your code (adding the required import strutils) when entering your sequence followed by another 4, nan or empty line (the latter erroring on invalid float).



For easier testing, I put your input in a file input.txt:



7
1
4
4
nan
4


and ran the following on the latest stable nim (Nim Compiler Version 0.19.4 [Linux: amd64]) as the latest devel nim (Nim Compiler Version 0.19.9 [Linux: amd64]):



import strutils

var
line: TaintedString
timeSeries: seq[float]

echo timeSeries
for line in "input.txt".lines:
timeSeries.add(parseFloat(line.strip))
echo timeSeries


(the .strip is only there to handle trailing spaces in the input that were a result of cut-and-paste and sloppy editing)



Both compilers output:



@[]
@[7.0]
@[7.0, 1.0]
@[7.0, 1.0, 4.0]
@[7.0, 1.0, 4.0, 4.0]
@[7.0, 1.0, 4.0, 4.0, nan]
@[7.0, 1.0, 4.0, 4.0, nan, 4.0]


compiling with -d:release did not cause any errors either.






share|improve this answer

























  • I could reproduce your example, it works for me as well. I will investigate why it failed in my initial try (could not reproduce this quickly though)

    – smartmic
    Mar 23 at 8:49











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55308634%2fpopulate-sequence-containing-nan%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Since you echo timeSeries before you add the next number, the input of the last line with 4 causes the @[7.0, 1.0, 4.0, 4.0, nan] and it is guesswork what you did after that to get the final output line. Although I doubt there is a valid reason for anything to set every value in the sequence to NaN, it might be that what your input triggered a bug.



I have not been able to reproduce your output
with your code (adding the required import strutils) when entering your sequence followed by another 4, nan or empty line (the latter erroring on invalid float).



For easier testing, I put your input in a file input.txt:



7
1
4
4
nan
4


and ran the following on the latest stable nim (Nim Compiler Version 0.19.4 [Linux: amd64]) as the latest devel nim (Nim Compiler Version 0.19.9 [Linux: amd64]):



import strutils

var
line: TaintedString
timeSeries: seq[float]

echo timeSeries
for line in "input.txt".lines:
timeSeries.add(parseFloat(line.strip))
echo timeSeries


(the .strip is only there to handle trailing spaces in the input that were a result of cut-and-paste and sloppy editing)



Both compilers output:



@[]
@[7.0]
@[7.0, 1.0]
@[7.0, 1.0, 4.0]
@[7.0, 1.0, 4.0, 4.0]
@[7.0, 1.0, 4.0, 4.0, nan]
@[7.0, 1.0, 4.0, 4.0, nan, 4.0]


compiling with -d:release did not cause any errors either.






share|improve this answer

























  • I could reproduce your example, it works for me as well. I will investigate why it failed in my initial try (could not reproduce this quickly though)

    – smartmic
    Mar 23 at 8:49















1














Since you echo timeSeries before you add the next number, the input of the last line with 4 causes the @[7.0, 1.0, 4.0, 4.0, nan] and it is guesswork what you did after that to get the final output line. Although I doubt there is a valid reason for anything to set every value in the sequence to NaN, it might be that what your input triggered a bug.



I have not been able to reproduce your output
with your code (adding the required import strutils) when entering your sequence followed by another 4, nan or empty line (the latter erroring on invalid float).



For easier testing, I put your input in a file input.txt:



7
1
4
4
nan
4


and ran the following on the latest stable nim (Nim Compiler Version 0.19.4 [Linux: amd64]) as the latest devel nim (Nim Compiler Version 0.19.9 [Linux: amd64]):



import strutils

var
line: TaintedString
timeSeries: seq[float]

echo timeSeries
for line in "input.txt".lines:
timeSeries.add(parseFloat(line.strip))
echo timeSeries


(the .strip is only there to handle trailing spaces in the input that were a result of cut-and-paste and sloppy editing)



Both compilers output:



@[]
@[7.0]
@[7.0, 1.0]
@[7.0, 1.0, 4.0]
@[7.0, 1.0, 4.0, 4.0]
@[7.0, 1.0, 4.0, 4.0, nan]
@[7.0, 1.0, 4.0, 4.0, nan, 4.0]


compiling with -d:release did not cause any errors either.






share|improve this answer

























  • I could reproduce your example, it works for me as well. I will investigate why it failed in my initial try (could not reproduce this quickly though)

    – smartmic
    Mar 23 at 8:49













1












1








1







Since you echo timeSeries before you add the next number, the input of the last line with 4 causes the @[7.0, 1.0, 4.0, 4.0, nan] and it is guesswork what you did after that to get the final output line. Although I doubt there is a valid reason for anything to set every value in the sequence to NaN, it might be that what your input triggered a bug.



I have not been able to reproduce your output
with your code (adding the required import strutils) when entering your sequence followed by another 4, nan or empty line (the latter erroring on invalid float).



For easier testing, I put your input in a file input.txt:



7
1
4
4
nan
4


and ran the following on the latest stable nim (Nim Compiler Version 0.19.4 [Linux: amd64]) as the latest devel nim (Nim Compiler Version 0.19.9 [Linux: amd64]):



import strutils

var
line: TaintedString
timeSeries: seq[float]

echo timeSeries
for line in "input.txt".lines:
timeSeries.add(parseFloat(line.strip))
echo timeSeries


(the .strip is only there to handle trailing spaces in the input that were a result of cut-and-paste and sloppy editing)



Both compilers output:



@[]
@[7.0]
@[7.0, 1.0]
@[7.0, 1.0, 4.0]
@[7.0, 1.0, 4.0, 4.0]
@[7.0, 1.0, 4.0, 4.0, nan]
@[7.0, 1.0, 4.0, 4.0, nan, 4.0]


compiling with -d:release did not cause any errors either.






share|improve this answer















Since you echo timeSeries before you add the next number, the input of the last line with 4 causes the @[7.0, 1.0, 4.0, 4.0, nan] and it is guesswork what you did after that to get the final output line. Although I doubt there is a valid reason for anything to set every value in the sequence to NaN, it might be that what your input triggered a bug.



I have not been able to reproduce your output
with your code (adding the required import strutils) when entering your sequence followed by another 4, nan or empty line (the latter erroring on invalid float).



For easier testing, I put your input in a file input.txt:



7
1
4
4
nan
4


and ran the following on the latest stable nim (Nim Compiler Version 0.19.4 [Linux: amd64]) as the latest devel nim (Nim Compiler Version 0.19.9 [Linux: amd64]):



import strutils

var
line: TaintedString
timeSeries: seq[float]

echo timeSeries
for line in "input.txt".lines:
timeSeries.add(parseFloat(line.strip))
echo timeSeries


(the .strip is only there to handle trailing spaces in the input that were a result of cut-and-paste and sloppy editing)



Both compilers output:



@[]
@[7.0]
@[7.0, 1.0]
@[7.0, 1.0, 4.0]
@[7.0, 1.0, 4.0, 4.0]
@[7.0, 1.0, 4.0, 4.0, nan]
@[7.0, 1.0, 4.0, 4.0, nan, 4.0]


compiling with -d:release did not cause any errors either.







share|improve this answer














share|improve this answer



share|improve this answer








edited Apr 6 at 7:55

























answered Mar 23 at 6:39









AnthonAnthon

33.1k1798152




33.1k1798152












  • I could reproduce your example, it works for me as well. I will investigate why it failed in my initial try (could not reproduce this quickly though)

    – smartmic
    Mar 23 at 8:49

















  • I could reproduce your example, it works for me as well. I will investigate why it failed in my initial try (could not reproduce this quickly though)

    – smartmic
    Mar 23 at 8:49
















I could reproduce your example, it works for me as well. I will investigate why it failed in my initial try (could not reproduce this quickly though)

– smartmic
Mar 23 at 8:49





I could reproduce your example, it works for me as well. I will investigate why it failed in my initial try (could not reproduce this quickly though)

– smartmic
Mar 23 at 8:49



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55308634%2fpopulate-sequence-containing-nan%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현