Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我如何获得第二个小数位0?
例如:
15.296326 => 15.30 15.245152 => 15.20
我已经尝试过toFixed(),Math.Floor但无法得到预期的答案。
toFixed()
Math.Floor
function roundFloat(n) { return (Math.round(n * 10) / 10).toFixed(2); } roundFloat(15.296326); // "15.30" roundFloat(15.245152); // "15.20"
我已经看到许多关于send()讨论底层协议的问题。我完全清楚,对于 TCP,任何消息都可能在发送时被分解成多个部分,并且不能保证接收者会在一次原子操作中获得消息。在这个问题中,我只讨论send()系统调用与本地系统的网络层交互时的行为。
send()
根据 POSIX 标准和send()我阅读的