[Info-vax] VMS Software Q1 '23 Update

Dan Cross cross at spitfire.i.gajendra.net
Wed Feb 1 12:23:40 EST 2023


In article <trdooi$blc0$1 at dont-email.me>,
Simon Clubley  <clubley at remove_me.eisner.decus.org-Earth.UFP> wrote:
>On 2023-01-31, Stephen Hoffman <seaohveh at hoffmanlabs.invalid> wrote:
>> On 2023-01-31 14:07:05 +0000, Simon Clubley said:
>>
>>> I would not disagree with that. Having never really used DEC Basic, I 
>>> had forgotten about them until you brought them up.
>>> 
>>> Did they exist back in the V4 days when David started writing his code ?
>>
>> VAX/VMS V3.x BASIC apps usually used integers, and used numeric strings 
>> via the VAX/VMS RTLs.
>>
>
>Actually, the V4 reference here was to RSTS/E, not VAX/VMS... :-)
>
>Interesting story however, and shows just how easy it is to screw up
>using FP.
>
>Something just occurred to me while writing this: does the latest solution
>to everything :-) (ie: Rust) still allow you to directly compare two floating
>point numbers ?
>
>Based on a quick search, the answer would appear to be yes, which was
>a bit of a surprise...

It depends on how you do it, but yes, Rust lets you compare
two floating point numbers for equality:

: igor; rustc --version
rustc 1.67.0 (fc594f156 2023-01-24)
: igor; cat >test.rs
fn main() {
    let x = 0.6;
    let y = 0.6;

    if x == y {
        println!("comparison on floats is true");
    }

    match x {
        0.6 => println!("match on floats...for now"),
        _ => println!("bah, humbug."),
    }
}
: igor; rustc test.rs
warning: floating-point types cannot be used in patterns
  --> test.rs:10:9
   |
10 |         0.6 => println!("match on floats...for now"),
   |         ^^^
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
   = note: `#[warn(illegal_floating_point_literal_pattern)]` on by default

warning: 1 warning emitted

: igor; ./test
comparison on floats is true
match on floats...for now
: igor;

Note the warning on `match` against floats.

I suspect that tests for equality are permitted since testing
for partial equality (e.g., <=, >=) may be important and there's
not an easy way to turn off equality testing if you support
partial orderings.

Note that Rust does treat things somewhat specially when it
comes to floating point.  cf the PartialOrd and PartialEq
traits:
https://doc.rust-lang.org/std/cmp/trait.PartialEq.html
https://doc.rust-lang.org/std/cmp/trait.PartialOrd.html

	- Dan C.




More information about the Info-vax mailing list