<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"\@Adobe Song Std L";
        panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {mso-style-priority:99;
        mso-style-link:"Plain Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
span.PlainTextChar
        {mso-style-name:"Plain Text Char";
        mso-style-priority:99;
        mso-style-link:"Plain Text";
        font-family:"Calibri","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoPlainText" style="margin-left:.5in">> -          tracef doesn't have a format option for Booleans, forcing<o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:.5in">> me to convert them to strings. Running @toInt on a Boolean produces:<o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:.5in">> "java.lang.NumberFormatException: For input string: "false"".<o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:.5in"><o:p> </o:p></p>
<p class="MsoPlainText" style="margin-left:.5in">I think the documentation is lying (by omission) about that. Try "%b".<o:p></o:p></p>
<p class="MsoPlainText">Thanks!<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText" style="margin-left:.5in">All of "True" and "true" and "TRUE" and "tRuE" (and all other case<o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:.5in">combinations) should work. The implementation uses Java's Boolean.valueOf(String), which calls this:<o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:.5in">    private static boolean toBoolean(String name) {<o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:.5in">        return ((name != null) && name.equalsIgnoreCase("true"));<o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:.5in">    }<o:p></o:p></p>
<p class="MsoPlainText">Great! I must have had another bug that I thought was caused by mis-parsing of file contents.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Greg Bronevetsky<o:p></o:p></p>
<p class="MsoPlainText">Lawrence Livermore National Lab<o:p></o:p></p>
<p class="MsoPlainText">(925) 424-5756<o:p></o:p></p>
<p class="MsoPlainText">bronevetsky@llnl.gov<o:p></o:p></p>
<p class="MsoPlainText">http://greg.bronevetsky.com<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">-----Original Message-----<br>
From: Mihael Hategan [mailto:hategan@mcs.anl.gov] <br>
Sent: Monday, May 19, 2014 4:29 PM<br>
To: Bronevetsky, Greg<br>
Cc: swift-user@ci.uchicago.edu<br>
Subject: Re: [Swift-user] Treatment of booleans in Swift</p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">On Mon, 2014-05-19 at 23:22 +0000, Bronevetsky, Greg wrote:<o:p></o:p></p>
<p class="MsoPlainText">> I've been working with Booleans recently and I've run into a couple of issues with them that might be a problem for others:<o:p></o:p></p>
<p class="MsoPlainText">> <o:p></o:p></p>
<p class="MsoPlainText">> -          tracef doesn't have a format option for Booleans, forcing<o:p></o:p></p>
<p class="MsoPlainText">> me to convert them to strings. Running @toInt on a Boolean produces:<o:p></o:p></p>
<p class="MsoPlainText">> "java.lang.NumberFormatException: For input string: "false"".<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">I think the documentation is lying (by omission) about that. Try "%b".<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">> <o:p></o:p></p>
<p class="MsoPlainText">> -          It is not clear how to format files to be read by<o:p></o:p></p>
<p class="MsoPlainText">> readData() if the data in question is a Boolean. Based on
<o:p></o:p></p>
<p class="MsoPlainText">> experimentation I discovered that the correct strings are
<o:p></o:p></p>
<p class="MsoPlainText">> "True"/"False" rather than "true"/"false" or "0"/"1". It would be
<o:p></o:p></p>
<p class="MsoPlainText">> useful to document this in the description of readData().<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">All of "True" and "true" and "TRUE" and "tRuE" (and all other case<o:p></o:p></p>
<p class="MsoPlainText">combinations) should work. The implementation uses Java's Boolean.valueOf(String), which calls this:<o:p></o:p></p>
<p class="MsoPlainText">    private static boolean toBoolean(String name) {<o:p></o:p></p>
<p class="MsoPlainText">        return ((name != null) && name.equalsIgnoreCase("true"));<o:p></o:p></p>
<p class="MsoPlainText">    }<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Mihael<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
</div>
</body>
</html>