N
Nathanial Allan
I have come across a strange occurance when I use the space ship
operator to compare percentages.
I want to compare percentages to see if they are greater than, less than
or equal to 85%, this mostly works fine - all the way up to 99% - it
returns a 1 obviously meaning that 99% is greater than 85%
however the strangeness comes in when I attempt to compare 100% or
greater against 85% - it returns -1
I am fairly new to ruby - by no means an expert so I suspect there is
something wrong with what I am doing rather than the spaceship operator.
Can someone please shine some light on this for me so that I may better
understand.
I have the knowledge to perform this operation another way with differnt
code, but I am interested to know why - if there is a logical
explaination.
Thanks in advance!
operator to compare percentages.
I want to compare percentages to see if they are greater than, less than
or equal to 85%, this mostly works fine - all the way up to 99% - it
returns a 1 obviously meaning that 99% is greater than 85%
however the strangeness comes in when I attempt to compare 100% or
greater against 85% - it returns -1
I am fairly new to ruby - by no means an expert so I suspect there is
something wrong with what I am doing rather than the spaceship operator.
Can someone please shine some light on this for me so that I may better
understand.
I have the knowledge to perform this operation another way with differnt
code, but I am interested to know why - if there is a logical
explaination.
Thanks in advance!