Pure Programmer
Blue Matrix


Cluster Map

Project: Expressions

Write a program that computes and prints the values for [[Golden Ratio]], [[√2]], [[cos]] [[π]]/4, [[log]]₂ 13 and [[Natural_logarithm|ln]] [[E_(mathematical_constant)|𝑒]]

Output
$ rustc Expressions.rs error[E0425]: cannot find value `PI` in this scope --> Expressions.rs:12:31 | 12 | println!("cos(π/4): {}", cos(PI / 4.f64)); | ^^ not found in this scope | help: consider importing one of these items | 7 + use consts::PI; | 7 + use std::f32::consts::PI; | error[E0425]: cannot find value `E` in this scope --> Expressions.rs:14:27 | 14 | println!("ln ℯ: {}", log(E)); | ^ not found in this scope | help: consider importing one of these items | 7 + use consts::E; | 7 + use std::f32::consts::E; | warning: unused import: `std::f64::consts` --> Expressions.rs:7:5 | 7 | use std::f64::consts; | ^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> Expressions.rs:10:31 | 10 | println!("\u{1D711}: {}", (1.f64 + sqrt(5.f64)) / 2.f64); | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 10 | println!("\u{1D711}: {}", (1.0f64 + sqrt(5.f64)) / 2.f64); | + error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> Expressions.rs:10:44 | 10 | println!("\u{1D711}: {}", (1.f64 + sqrt(5.f64)) / 2.f64); | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 10 | println!("\u{1D711}: {}", (1.f64 + sqrt(5.0f64)) / 2.f64); | + error[E0425]: cannot find function `sqrt` in this scope --> Expressions.rs:10:37 | 10 | println!("\u{1D711}: {}", (1.f64 + sqrt(5.f64)) / 2.f64); | ^^^^ not found in this scope error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> Expressions.rs:10:54 | 10 | println!("\u{1D711}: {}", (1.f64 + sqrt(5.f64)) / 2.f64); | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 10 | println!("\u{1D711}: {}", (1.f64 + sqrt(5.f64)) / 2.0f64); | + error[E0425]: cannot find function `sqrt` in this scope --> Expressions.rs:11:28 | 11 | println!("\u{221A}2: {}", sqrt(2.0f64)); | ^^^^ not found in this scope | help: use the `.` operator to call the method `sqrt` on `f64` | 11 - println!("\u{221A}2: {}", sqrt(2.0f64)); 11 + println!("\u{221A}2: {}", 2.0f64.sqrt()); | error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> Expressions.rs:12:38 | 12 | println!("cos(π/4): {}", cos(PI / 4.f64)); | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 12 | println!("cos(π/4): {}", cos(PI / 4.0f64)); | + error[E0425]: cannot find function `cos` in this scope --> Expressions.rs:12:27 | 12 | println!("cos(π/4): {}", cos(PI / 4.f64)); | ^^^ not found in this scope error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> Expressions.rs:13:40 | 13 | println!("log\u{2082} 13: {}", log(13.f64) / log(2.f64)); | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 13 | println!("log\u{2082} 13: {}", log(13.0f64) / log(2.f64)); | + error[E0425]: cannot find function `log` in this scope --> Expressions.rs:13:33 | 13 | println!("log\u{2082} 13: {}", log(13.f64) / log(2.f64)); | ^^^ not found in this scope error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> Expressions.rs:13:53 | 13 | println!("log\u{2082} 13: {}", log(13.f64) / log(2.f64)); | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 13 | println!("log\u{2082} 13: {}", log(13.f64) / log(2.0f64)); | + error[E0425]: cannot find function `log` in this scope --> Expressions.rs:13:47 | 13 | println!("log\u{2082} 13: {}", log(13.f64) / log(2.f64)); | ^^^ not found in this scope error[E0425]: cannot find function `log` in this scope --> Expressions.rs:14:23 | 14 | println!("ln ℯ: {}", log(E)); | ^^^ not found in this scope error: aborting due to 14 previous errors; 1 warning emitted Some errors have detailed explanations: E0425, E0610. For more information about an error, try `rustc --explain E0425`.

Solution