Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACER card 2 doesn't accept some valid suffixes #31

Open
paulromano opened this issue Sep 3, 2021 · 3 comments
Open

ACER card 2 doesn't accept some valid suffixes #31

paulromano opened this issue Sep 3, 2021 · 3 comments

Comments

@paulromano
Copy link
Member

In ACER/Card2/Suff.hpp, there's an interesting check on the value that is given:

if( int(s*100)%100 == double(s*100) ) { return true; }

However, this logic doesn't work for some valid suffixes. I ran into this when trying to use .07, upon which NJOY21 complained:

[error] Encountered invalid value for suff
[info] Error while parsing line 79

2 0 1 .07 /
~~~~~~^

[info] 
The suff parameter specifies the suffix of the ZAID. It is appended 
to the ZA for the material. 

It is a two-digit float (e.g., .70, .71, .80). The 
default value is .00. 

Specifying a negative value when iopt=7--9 leaves the old 
ZAID unchanged (from previous ACER run).

[info] Trouble validating Card2
[info] Trouble validating ACER input.
[info] Error while running NJOY21

The suffix .07 is just one example that doesn't work but there are a whole bunch more. A simple Python script demonstrates this:

>>> for i in range(100):
...     s = i / 100
...     print(f"{i:02}", int(s*100)%100 == float(s*100))
... 
00 True
01 True
02 True
03 True
04 True
05 True
06 True
07 False
08 True
09 True
10 True
11 True
12 True
13 True
14 False
15 True
16 True
17 True
18 True
19 True
20 True
21 True
22 True
23 True
24 True
25 True
26 True
27 True
28 False
29 False
30 True
31 True
32 True
33 True
34 True
35 True
36 True
37 True
38 True
39 True
40 True
41 True
42 True
43 True
44 True
45 True
46 True
47 True
48 True
49 True
50 True
51 True
52 True
53 True
54 True
55 False
56 False
57 False
58 False
59 True
60 True
61 True
62 True
63 True
64 True
65 True
66 True
67 True
68 True
69 True
70 True
71 True
72 True
73 True
74 True
75 True
76 True
77 True
78 True
79 True
80 True
81 True
82 True
83 True
84 True
85 True
86 True
87 True
88 True
89 True
90 True
91 True
92 True
93 True
94 True
95 True
96 True
97 True
98 True
99 True
@nathangibson14
Copy link
Contributor

Thanks, Paul. That's some bizarre behavior. But in any case, I'm getting good at correcting lipservice problems, so I'll work on this as soon as I can.

@paulromano
Copy link
Member Author

Thanks @nathangibson14! Yeah, it's a little strange, but I'm not too surprised -- pretty easy to get yourself in trouble by comparing floats like this. My guess is that the LHS ends up as 7.0 and the RHS ends up as 7.0000000000001 or something like that.

@nathangibson14
Copy link
Contributor

nathangibson14 commented Sep 4, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants