3 ms·
The idea is mostly that we shouldn't worry. The user of the lib on an arduino will feed it arduino sized problems and the amd64 user will likewise larger proble
by donkeybeer 9mo ago
The idea is mostly that we shouldn't worry. The user of the lib on an arduino will feed it arduino sized problems and the amd64 user will likewise larger problems. Again I think just think of the transition from 32 to 64 bit. Most ranges are "input"/"user " dependent and it would have been needlessly messy to have to even with automatic conversion help rewrite say every i32 to i64 or which ones to convert.
- direwolf20 9mo agoThat's size_t. What about counting milliseconds?
- donkeybeer 9mo agoAs I said, today when it really matters we can use stdint. But I feel it would have been too burdensome to mandate on the standard in the early days of C.
- Borg3 9mo agoLike fucking what? If you do any TS.. you just use unsigned whatever fastest type you have on targeting platform, and you do NOT care. 16bit? wrapping at 1 min? Thats eternity even on 2MHz 6502... You just count and substract to get difference. Usually you are <1000ms range.. so wrapping is not a problem.. If you target about 32bit and 16bit, you either think about and using long (on 16 bit is more costly) or you just count seconds.. Or ticks.. or whatever you need.
- direwolf20 9mo agocool, it's an app that lets me set a 2 minute timer and counts in milliseconds, oh what's that, it doesn't work right on Arduino
- Borg3 9mo agoThen use long.. Does Arduino CPU cannot do 16bit add/sub with carry? wtf?
- direwolf20 9mo agoI'm not writing the app. The app was written according to your preferred design and I'm compiling it for Arduino. You say to just use int because it always has enough bits, then you say to sometimes use long because int might not have enough bits.
- 1718627440 9mo agoThere is a platform where int has less than the prescribed 16 bits? How much does it have then, just 8bit or something weird?
- direwolf20 9mo agoArduino has 16-bit int, so the timer app will work up to 32.767 or 65.535 seconds, that is less than two minutes.
- 1718627440 9mo agoWhen you choose unsigned int for that type, you compare against UINT_MAX and return an EOVERFLOW, ENOMEM, EOUT_OF_RANGE or whatever you like when someone sets a timer greater than that. Or you choose another type, i.e. unsigned long which is guaranteed to take values to at least 4294967295. I happen to program for the Arduino platform recently and milliseconds in the Arduino API are typed unsigned long. If your decision is that you really want to store all 32-bit values then you use uint_least32_t or uint_fast32_t depending if you are also resource constrained.
- direwolf20 9mo agoRight, so you can't just use int.