[Info-vax] Python for x86?
Arne Vajhøj
arne at vajhoej.dk
Tue May 9 21:47:11 EDT 2023
On 5/9/2023 8:34 PM, Chris Townley wrote:
> Still at least we got to the bottom of it. Using the % sign was part of
> our standards using VAX/DEC/Compaq/HP Basic
And an example that one should not blindly assume that
all programming languages follow the same conventions
about literals.
I actually already knew about such an example.
It is very very common that a language supports 123.45f for
32 bit FP and 123.45d for 64 bit FP and the language got some
standard for whether 123.45 default to 32 or 64 bit FP (aka
has an implicit f or d suffix).
Java:
public class WhatFP {
public static void printType(Object o) {
System.out.println(o.getClass().getName());
}
public static void main(String[] args) {
printType(123.45f);
printType(123.45d);
printType(123.45);
}
}
outputs:
java.lang.Float
java.lang.Double
java.lang.Double
works that way.
So one gets surprised when working with Groovy:
println(123.45f.class.name)
println(123.45d.class.name)
println(123.45.class.name)
outputs:
java.lang.Float
java.lang.Double
java.math.BigDecimal
Arne
More information about the Info-vax
mailing list