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

Number comparison problem #110

Closed
bthibault opened this Issue Apr 7, 2014 · 7 comments

Comments

Projects
None yet
2 participants
@bthibault
Copy link

bthibault commented Apr 7, 2014

Doug,

Maybe i'm doing something wrong,

But when I run rule matching on this expression, matching fails

"79.00" == 79 .. in JSFiddle ofcourse this evaluates to true.

Rule matching is working for this however...

"79.00" <= 100 -> true

It seems like that number comparison maybe getting translated somewhere down the stack.

Thanks

@doug-martin

This comment has been minimized.

Copy link
Contributor

doug-martin commented Apr 7, 2014

Nools uses a strict equals so your "79.00" will not === 79 however I do believe you can add parseInt("79.00", 10) == 79 but I have not tried it I will look at that a little later today. I would be open for a pull request that differentiates between ==, != === and !==

@bthibault

This comment has been minimized.

Copy link

bthibault commented Apr 7, 2014

Well really what I"m passing in is

p.price == 79

so I can't really do: parseInt(p.price, 10 )

at that the same time, I'm not sure that loosening the strict matching is an answer either, people can run into issues if they don't know what they're doing.

Let me know where I should I look, and I can take a gander. Looks like some of this is happening in contraints.js ... i'm not sure I can follow it w/ out a sequence diagram or a specific instructions but I can look nonetheless.

@bthibault

This comment has been minimized.

Copy link

bthibault commented Apr 7, 2014

Also this is why I hate dynamic type languages 🔢 , makes everything more complicated

@bthibault

This comment has been minimized.

Copy link

bthibault commented Apr 8, 2014

Doug,

Let me know if you had a chance to look at this or where I would update this at. This is a blocker as I'm about to roll Nools out into production.

@bthibault

This comment has been minimized.

Copy link

bthibault commented Apr 8, 2014

Okay I got this working by a hack:

parseInt didn't work, but i was able to do this:

// p.price = '79.00'

(p.price * 1) == 79 // true

It makes sense that 'price' should be a float to begin with... but part of what I'm using Nools for is data normalization so its important that I get it working from the nools end. Anyway were good for now

doug-martin added a commit to doug-martin/nools that referenced this issue May 18, 2014

v0.3.0
* Added new `===` and `!==` operators [noolsjs#110](noolsjs#110)
* Fix for issue [noolsjs#109](noolsjs#109)
* Updated Readme
    * Updated agenda groups examples for [noolsjs#105](noolsjs#105)

@doug-martin doug-martin referenced this issue May 18, 2014

Merged

v0.3.0 #114

doug-martin added a commit to doug-martin/nools that referenced this issue May 18, 2014

v0.3.0
* Added new `===` and `!==` operators noolsjs#110
* Fix for issue noolsjs#109
* Updated Readme
    * Updated agenda groups examples for noolsjs#105
    * Changed class names not to match property names in readme noolsjs#99

doug-martin added a commit to doug-martin/nools that referenced this issue May 18, 2014

v0.3.0
* Added new `===` and `!==` operators noolsjs#110
* Fix for issue noolsjs#109
* Updated Readme
    * Updated agenda groups examples for noolsjs#105
    * Changed class names not to match property names in readme noolsjs#99
@doug-martin

This comment has been minimized.

Copy link
Contributor

doug-martin commented May 18, 2014

Ok I added ===, and !== to v0.3.0 I did this since we are using javascript and I this hasnt just tripped you up but other people also. I wrote the constraints parser to be as close to Javascript as possible and the lack of differentiation of strict equality is something that I should have had since the beginning.

I hope this helps.

-Doug

@bthibault

This comment has been minimized.

Copy link

bthibault commented Jun 4, 2014

Thanks Doug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment