REBOL3 tracker
  0.9.11 beta
Ticket #0001622 User: anonymous

Project:

Previous Next
TypeBug Statussubmitted Date20-Jun-2010 09:52
Versionalpha 99 CategoryUnspecified Submitted byLadislav
PlatformAll Severityminor Prioritynormal

Summary EVEN?, ODD? and decimals
Description I consider a value to be even only if it is an integral multiple of two. This means, that for me, 2.1 is not even.

This, begs a question, how the ODD? function shall be defined, there are two alternatives:

1) ODD? means the same as NOT EVEN?, in this case, 2.1 would need to be odd

2) ODD? means, that the value is:
2.1) integral (having zero remainder when divided by 1.0)
2.2) not even
, in this case 2.1 would need to be neither even nor odd
Example code
>> even? 2.1
== true

Assigned ton/a Fixed in- Last Update25-Jun-2010 08:55


Comments
(0002398)
Ladislav
25-Jun-2010 08:55

To be even more specific, here are my alternative functions to consider:

alternative-even?: func [
number [decimal!]
] [
zero? number // 2.0
]

alternative-odd?: func [
number [decimal!]
] [
found? all [
zero? number // 1.0
not zero? number // 2.0
]
]

; some results:
>> alternative-even? 2.1
== false

>> alternative-even? 2.0
== true

>> alternative-odd? 2.0
== false

>> alternative-odd? 2.1
== false

>> alternative-odd? 1.1
== false

>> alternative-odd? 1.0
== true

Date User Field Action Change
25-Jun-2010 08:55 Ladislav Comment : 0002398 Added -
20-Jun-2010 09:55 Ladislav Description Modified -
20-Jun-2010 09:53 Ladislav Summary Modified EVEN? and decimals => EVEN?, ODD? and decimals
20-Jun-2010 09:53 Ladislav Description Modified -
20-Jun-2010 09:53 Ladislav Code Modified -
20-Jun-2010 09:52 Ladislav Ticket Added -