Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#Ceil and Floor

Ceil and Floor

If you ever want to get the rounded-up result for a division, much like you'd do with // for floor, you could use math.ceil(3/2) for 15 or the much shorter -(-3//2) for 8 bytes.

math.floor(n) : 13 bytes+12 for import
n//1 : 4 bytes
math.ceil(n) : 12 bytes+12 for import
-(-n//1) : 8 bytes

#Ceil and Floor

If you ever want to get the rounded-up result for a division, much like you'd do with // for floor, you could use math.ceil(3/2) for 15 or the much shorter -(-3//2) for 8 bytes.

math.floor(n) : 13 bytes+12 for import
n//1 : 4 bytes
math.ceil(n) : 12 bytes+12 for import
-(-n//1) : 8 bytes

Ceil and Floor

If you ever want to get the rounded-up result for a division, much like you'd do with // for floor, you could use math.ceil(3/2) for 15 or the much shorter -(-3//2) for 8 bytes.

math.floor(n) : 13 bytes+12 for import
n//1 : 4 bytes
math.ceil(n) : 12 bytes+12 for import
-(-n//1) : 8 bytes
added 28 characters in body
Source Link
Juan Cortés
  • 1.6k
  • 13
  • 20

#Ceil and Floor

If you ever want to get the rounded-up result for a division, much like you'd do with // for floor, you could use math.ceil(3/2) for 15 or the much shorter -(-3//2) for 8 bytes.

math.floor(n) : 13 bytesbytes+12 for import
n//1 : 4 bytes
math.ceil(n) : 12 bytesbytes+12 for import
-(-n//1) : 8 bytes

#Ceil and Floor

If you ever want to get the rounded-up result for a division, much like you'd do with // for floor, you could use math.ceil(3/2) for 15 or the much shorter -(-3//2) for 8 bytes.

math.floor(n) : 13 bytes
n//1 : 4 bytes
math.ceil(n) : 12 bytes
-(-n//1) : 8 bytes

#Ceil and Floor

If you ever want to get the rounded-up result for a division, much like you'd do with // for floor, you could use math.ceil(3/2) for 15 or the much shorter -(-3//2) for 8 bytes.

math.floor(n) : 13 bytes+12 for import
n//1 : 4 bytes
math.ceil(n) : 12 bytes+12 for import
-(-n//1) : 8 bytes
deleted 140 characters in body
Source Link
mbomb007
  • 23.6k
  • 7
  • 66
  • 143

I doubt this will get much attention#Ceil and hope I'm not repeating it, I search for ceil on all pages but couldn't find anything.Floor

If you ever want to get the rounded-up result for a division, much like you'd do with // for floor, you cancould use Mathmath.ceil(3/2) for 15 or the much cryptic and shorter -(-3//2) for 8. Saving 8b in the process bytes.

3//2 math.floor(n) : 13 bytes
n//1 :1 - 4b
-(-3//2) :2 -4 8b bytes

math.floorceil(3/2n):1 -12 15bbytes
math.ceil-(3-n/2/1) :2 -8 14b bytes

I doubt this will get much attention and hope I'm not repeating it, I search for ceil on all pages but couldn't find anything. If you ever want to get the rounded-up result for a division, much like you'd do with // for floor, you can use Math.ceil(3/2) for 15 or the much cryptic and shorter -(-3//2) for 8. Saving 8b in the process.

3//2  :1 - 4b
-(-3//2) :2 - 8b
math.floor(3/2):1 - 15b
math.ceil(3/2) :2 - 14b

#Ceil and Floor

If you ever want to get the rounded-up result for a division, much like you'd do with // for floor, you could use math.ceil(3/2) for 15 or the much shorter -(-3//2) for 8 bytes.

math.floor(n) : 13 bytes
n//1 : 4  bytes

math.ceil(n): 12 bytes
-(-n//1) : 8  bytes
deleted 1 character in body
Source Link
Juan Cortés
  • 1.6k
  • 13
  • 20
Loading
Source Link
Juan Cortés
  • 1.6k
  • 13
  • 20
Loading

AltStyle によって変換されたページ (->オリジナル) /