Quick actions

cmd+k|ctrl+k

Navigation

Languages

number

Snippet info

Language

Python

Visibility

public

Author

hltse59

Created

2024-04-10T04:55:35.824789Z

Updated

2024-04-10T04:55:35.824789Z

import math
a = 33
b = 16
print(a/b)				# 2.0625
print(a//b)				# 2
print(math.floor(a/b))	# 2
# negative number	
a = -33
b = 16
print('{0}/{1} = {2}'.format(a, b, a/b))					# -33/16 = -2.0625
print('trunc({0}/{1}) = {2}'.format(a,b,math.trunc(a/b)))		# trunc(-33/16) = -2
print('{0}//{1} = {2}'.format(a, b, a//b))					# -33//16 = -3
print('floor({0}//{1}) = {2}'.format(a, b, math.floor(a/b)))	# floor(-33//16) = -3
# negative %(mod) is come from “modulo operator a = b * (a//b) + (a%b)”
INFO