Rust language adds algebraic floating-point methods

“For example, floating-point addition is not associative, so a sum like a + b + c + d must be evaluated in the left-associative order in which it is parsed, like ((a + b) + c) + d,” the Rust team noted. “If you write the same sum as a chain of algebraic_add calls, then the compiler is free to reorder it, perhaps like (a + b) + (c + d) to evaluate the partial sums simultaneously. Broader loop-vectorization is often enabled by using these algebraic methods as well.”

The methods are non-deterministic, because the compiler is free to choose different optimizations, but they never cause undefined behavior, the Rust team said.

Rust 1.98.0 also introduces buffered integer formatting. All primitive integer types now have a format_into method that takes a &mut NumBuffer parameter, which is a buffer large enough to hold the decimal format of any value of the type. The format_into method returns the formatted &str with a lifetime borrowed from the buffer, and bypasses much of the dynamic dispatch of buffered write! formatting, improving performance.

Donner Music, make your music with gear
Multi-Function Air Blower: Blowing, suction, extraction, and even inflation

Leave a reply

Please enter your comment!
Please enter your name here