Float special text
Console program81 lines of .st148 lines of generated Cbuilds as C and Rust
Float: nan nan inf -inf 3000.000000 Float64: nan nan inf -inf [nan|nan|-inf]
On this page
The .st files#
intent.st
structop {
type_app {
exec = {
lang = "C"
}
}
lib_provider {
core = {
source = "StructOp/core"
version = "@latest"
}
}
}main.st
# Language 8.4.1: a Float or Float64 that is not a number prints nan (never -nan or NaN, whatever its
# sign), infinities inf and -inf, in printing and in text built with ${} into a String; both targets.
ability "value" "big" {
type = Float
initial = 300000000000000000000000000000000000000.0
}
data "value" "big" {
of = ability.value.big
}
ability "value" "inf" {
type = Float
}
data "value" "inf" {
of = ability.value.inf
}
ability "value" "wide" {
type = Float64
}
data "value" "wide" {
of = ability.value.wide
}
ability "value" "line" {
type = String
size = 80
}
data "value" "line" {
of = ability.value.line
}
ability "set" "Inf" {
target = ability.value.inf
value = data.value.big.current * 10.0
}
ability "set" "Wide" {
target = ability.value.wide
value = float64(data.value.inf.current)
depends_on = [ability.set.Inf]
}
ability "print" "Float" {
message = "Float: ${data.value.inf.current - data.value.inf.current} ${-(data.value.inf.current - data.value.inf.current)} ${data.value.inf.current} ${-data.value.inf.current} ${data.value.big.current / 100000000000000000000000000000000000.0}"
depends_on = [ability.set.Wide]
}
ability "print" "Float64" {
message = "Float64: ${data.value.wide.current - data.value.wide.current} ${-(data.value.wide.current - data.value.wide.current)} ${data.value.wide.current} ${-data.value.wide.current}"
depends_on = [ability.print.Float]
}
ability "set" "Line" {
target = ability.value.line
value = "[${data.value.inf.current - data.value.inf.current}|${-(data.value.wide.current - data.value.wide.current)}|${-data.value.wide.current}]"
depends_on = [ability.print.Float64]
}
ability "print" "Line" {
message = "${data.value.line.current}"
depends_on = [ability.set.Line]
}Input, plan and generated C#
structop plan
structop plan
# program.app will be created
+ program.app (.structop/build/app)
+ ability.value.big
+ ability.value.inf
+ ability.value.wide
+ ability.value.line
+ ability.set.Inf
+ ability.set.Wide
+ ability.print.Float
+ ability.print.Float64
+ ability.set.Line
+ ability.print.Line
Plan: 1 to add, 0 to change, 0 to destroy.Generated main.c
To inspect this generated file, select C in intent.st, initialize the project and export its source.
Export locally
structop init
structop apply -source -no-runGenerated main.rs (the same .st built as Rust)
To inspect this generated file, select Rust in intent.st, initialize the project and export its source.
Export locally
structop init
structop apply -source -no-runTry it
cd float-special-text # a folder holding the .st files above
structop init
structop plan
structop apply