4 ms·
Many of the numbers we use day to day are more like strings than actual integers, though. What sense does it make to divide by a zip code, or two add two zip co
by vageli 6y ago
Many of the numbers we use day to day are more like strings than actual integers, though. What sense does it make to divide by a zip code, or two add two zip codes together for instance?
- Alex3917 6y agoThis. Just because something contains numbers doesn't mean that it's numeric. Times aren't numbers because 6pm * 7am doesn't yield a meaningful result. Same thing with serial numbers, VIN numbers, building floor numbers, phone numbers, etc. All of those should always be strings, because performing "math" on them wouldn't yield meaningful results.
- MaxDPS 6y agoI work in ecommerce and deal with this issue a TON. I see it in things like GTIN/UPC or tracking numbers.
- chrisandchris 6y agoWhile I basically agree, there‘s a difference between „always send numbers as string“ and „send something that looks like a number but is actually a string as a string“. Why should i send a dimension as a string? How am I going to calculate the volume from 3 strings?
- Alex3917 6y ago> Why should i send a dimension as a string? You shouldn't because a dimension is a number. Something 4 feet long is twice as long as something 2 feet long.
- chrisandchris 6y agoMany != All So prices are numbers (if supplied in cents, the smallest unit). There is length/depth/height/weight/... A lot of things are actual numbers. Why supply them as string? I agree partially with you but think ZIP are a very bad example because a zip itself may also contain letters.