gpt4 book ai didi

flutter - 与Javascript Math.sign等效但与Dart等效

转载 作者:行者123 更新时间:2023-12-03 03:25:46 25 4
gpt4 key购买 nike

The Math.sign() function returns either a positive or negative +/- 1, indicating the sign of a number passed into the argument.. If the number passed into Math.sign() is 0, it will return a +/- 0. Note that if the number is positive, an explicit (+) will not be returned.



可以用 Dart 完成此操作-也许使用Maths库?我搜索了一下,但找不到太多。

最佳答案

不确定如何处理此问题,请删除它或回答它。 pskink提供的解决方案是使用不需要Dart Maths库的num.sign

它的用法如下:

var a = 5;
var b = -32;
var c = a.sign; //without ()
var d = b.sign;
print(c); // 1;
print(d); // -1;

而不是我使用的 sign(b)

关于flutter - 与Javascript Math.sign等效但与Dart等效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57637257/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com