Hi all,
I'd like to do something like that:
...
lastAlarm = content.parse("yyyy-MM-dd HH:mm:ss") # get last alarm date from a file
let delayAlarm = now() - lastAlarm # duration between now and last alarm
# trying to get the number of nbMin minutes in this delay
let lastAlarmResetLine = int(delayPastAlarm.inMinutes()) / int(initDuration(minutes = nbMin).inMinutes()) # if I do not cast in int, nim says it can not / two int64 !!!
Did I miss something or int64 are not managed for basic operations?
Regards, Fabien
Currently / for int64 is not directly supported although on a 64 bit system the division between int should be usable for int64.
See for context: https://github.com/nim-lang/Nim/issues/7920
I am on a 64 bits system (nim 1.4.0). If I undestood this thread, on 64 bits system int64 should be supported. Whatever the underlying system, it seems strange such behavior for basic type, that is used for Duration, so no direct operation on duration are possible, not that fun in real life.
Regards, Fabien
I agree I find it weird as well - but only as much as int/int does exist, as it gives a float results.
Do you want a float result? If so, it does make sense to cast them to float before division. Do you want an int result? use 'div' instead.
I agree that having int/int and not int64/int64 feels inconsistent, but I think it would be better resolved by removing the int/int, rather than by adding int64/int64 (although, removing int/int would harm backwards compatibility, so a bad idea)
I agree on everything. The odd behavior is having int/int. It is more idiomatic in Nim to require to explicitly convert to float.
Probably it would make sense in lenientops to add a division between someIntegers that does convert to float. I do not know how much lenientops is used though (I never use it).