Isn't time represented as numbers like floats; it is meaningless to test for equality. It's only meaningful to test for equality within a tolerance. This gives the, possibly unexpected, π != π (pi != pi).
The reason is that the first pi could be 3.14 while the second could be 3.14159265358979 ---- and the second is, of course, far from accurate.
On 2020.06.15 06:44, Jeff Gray wrote:
Hi all. In Playground I write these lines: Transcript cr; show: DateAndTime now printString. Transcript cr; show: (DateAndTime fromSeconds: (DateAndTime now asSeconds)) printString. and in the Transcript window I get these results: 2020-06-15T14:33:06.630367+10:00 2020-06-15T14:33:06+10:00 I was expecting these two to be the same. I was hoping to use DateAndTime fromSeconds: and aDateAndTime asSeconds to convert a DateAndTime to/from a number in order to store it in SQLite, but I don't like the way the nanos are dropped using this method. It's all good if I remember to call DateAndTime now truncated, and drop the nanos myself, but that might be all over the place in my application. Instead, is there a better way to convert a DateAndTime to and from a number? -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
--
The essence of object orientation is that objects collaborate to achieve a goal.
Trygve Reenskaug [hidden email]
Morgedalsvn. 5A http://folk.uio.no/trygver/
N-0378 Oslo http://fullOO.info
Norway Tel: (+47) 468 58 625
Free forum by Nabble | Edit this page |