Скажите, если вы хотите получить из таблицы только attr1
и attr2
, используя pets-index
, где ключ разделения pet_type
равен cats
, это должно работать:
response = table.query(
IndexName='pets-index',
KeyConditionExpression='pet_type = :value',
ExpressionAttributeValues={
':value': {'S': 'cats'}
},
ProjectionExpression='attr1,attr2'
)
Just cast one of the two operands to a float first.
v = (float)s / t;
The cast has higher precedence than the division, so happens before the division.
The other operand will be effectively automatically cast to a float by the compiler because the rules say that if either operand is of floating point type then the operation will be a floating point operation, even if the other operand is integral. Java Language Specification, §4.2.4 and §15.17
Приведите одно из целых чисел в число с плавающей точкой, чтобы заставить операцию выполняться с помощью математики с плавающей запятой. В противном случае целочисленная математика всегда предпочтительнее. Итак:
v = (float)s / t;
Попробуйте:
v = (float)s / (float)t;
Приведение целых чисел к плавающим допускает деление с плавающей запятой.
Тем не менее, вам действительно нужно разыграть только одно.
Вы можете разыграть хотя бы одного из них, но для согласованности вы можете явно разыграть оба, поэтому что-то вроде v = (float) s / (float) t должно работать ,
You can cast the numerator or the denominator to float...
int operations usually return int, so you have to change one of the operanding numbers.