mirror of
https://github.com/google/blockly.git
synced 2026-01-08 17:40:09 +01:00
Fix infinity in Python, PHP, and Dart.
This commit is contained in:
@@ -35,8 +35,17 @@ Blockly.Python.addReservedWords('math,random');
|
||||
Blockly.Python['math_number'] = function(block) {
|
||||
// Numeric value.
|
||||
var code = parseFloat(block.getFieldValue('NUM'));
|
||||
var order = code < 0 ? Blockly.Python.ORDER_UNARY_SIGN :
|
||||
Blockly.Python.ORDER_ATOMIC;
|
||||
var order;
|
||||
if (code == Infinity) {
|
||||
code = 'float("inf")';
|
||||
order = Blockly.Python.ORDER_FUNCTION_CALL;
|
||||
} else if (code == -Infinity) {
|
||||
code = '-float("inf")';
|
||||
order = Blockly.Python.ORDER_UNARY_SIGN;
|
||||
} else {
|
||||
order = code < 0 ? Blockly.Python.ORDER_UNARY_SIGN :
|
||||
Blockly.Python.ORDER_ATOMIC;
|
||||
}
|
||||
return [code, order];
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user